7 Replies Latest reply on Apr 19, 2016 8:07 PM by hsoehalim

    InAppBrowser doesn't open a page for the second time after close()

    hsoehalim Level 1

      Hi There,

       

      I was wondering if any of you guys ran into this problem before. I use this: cordova.InAppBrowser.open (siteUrl, "_blank", "location=no,toolbar=no"). What happen was the open() works the first time around. Then if I call close() and try open() method again the page doesn't open even though I can see the EventListener ('loadstop') is firing up.


      I'm using PhoneGap app to create the basic config.xml and https://build.phonegap.com (cli-5.2.0) to build my code.

      Here's a snippet of my code:

       

      onDeviceReady : function () {

              console.log ("device is ready");

              var site = app.openWebsite ("https://hostname1");

              site.close ();

              site = app.openWebsite ("https://hostname2");

      },

       

      openWebsite : function (siteUrl) {

              try {

                  var site = cordova.InAppBrowser.open (siteUrl, "_blank", "location=no,toolbar=no");

                  site.addEventListener ("loadstop", function (event) {

                      console.log (event.url);

                      //

                      // do something here...

                      //

                  });

                  site.addEventListener ("loaderror", function (event) {

                      alert ("ERROR - loaderror: " + event.message);

                  });

                  return site;

              } catch (error) {

                  alert ("ERROR - openWebsite(): " + error.message);

              }

      },

       

      Any help will be greatly appreciated.

       

      Thanks,

      Harry