Software Archive
Read-only legacy content
17060 Discussions

InAppBrowser only works on App Preview when using the WEINRE tag

Pedro_M_2
Beginner
570 Views

Hi,

I'm using Intel XDK 2611. I added the InAppBrowser plugin (cordova-plugin-inappbrowser) to my project and try to use it like this on iOS/IPad:
<span class="link" onclick="window.open('http://www.intel.com', '_blank');">Intel</span>

On the emulator everything is fine, but while testing the app using App Preview (either Mobile or Wifi), 9 times out of 10 the link will open in the app window, making it impossible for the user to go back. Sometimes, rarely, it will work as expected and present a "Done" button and navigation.

While trying to debug the problem, I noticed that InAppBrowser would always work as expected if I had the WEINRE tag as the first thing in my HTML. I have the cordova.js tag in my HTML, and tried to place it in various spots across the code with no success.

Is this an App Preview problem? Why would it work without problems just by having the WEINRE tag? What can I do?

0 Kudos
1 Solution
PaulF_IntelCorp
Employee
570 Views

WEINRE will slow down your app, so there may be a timing issue. I recommend that you do not use the inline onclick approach to adding a handler, and instead give the div an ID and then attach your click handler using JavaScript in a JS file. See how that is done in the "Blank Cordova Starter App" under "Samples and Demos" in the "General" category, under the "HTML5 + Cordova" section... there's a button there that get's hooked up using the technique I'm describing.

View solution in original post

0 Kudos
2 Replies
PaulF_IntelCorp
Employee
571 Views

WEINRE will slow down your app, so there may be a timing issue. I recommend that you do not use the inline onclick approach to adding a handler, and instead give the div an ID and then attach your click handler using JavaScript in a JS file. See how that is done in the "Blank Cordova Starter App" under "Samples and Demos" in the "General" category, under the "HTML5 + Cordova" section... there's a button there that get's hooked up using the technique I'm describing.

0 Kudos
Pedro_M_2
Beginner
570 Views

Thanks Paul, your answer set me on the right path.
The problem was that I was runing code before the device was ready. As soon as wrapped all my code in a function and called that function inside the "onDeviceReady" event handler, everything worked.

Thanks again!

0 Kudos
Reply