Cordova InAppBrowser opens a double window on Android

I have developed an application in Cordova 3.6 with the latest version of InAppBrowser. Launching on Android device (4.1.2 and others), when the user removes the link to open InAppBrowser, sometimes a double window appears. The second of these windows does not close.

To check if it was something I did in my application, I quickly created a standard Cordova hello world application and added the standard window.open code with a link like this

<a href="#" onclick="window.open('http://www.google.com','_blank')">OPEN WINDOW</a>

      

and basic testing on the device showed the same thing happened - sometimes a quick or double tap would make a double window open, one of which was bare. Either from <300ms double tap or double taps where the browser is slow to start.

It doesn't look like iOS.

Any help is greatly appreciated.

UPDATE

Part of the problem in my main application was functions declared in the wrong place (onpagecreate) that ran multiple times. I am posting this here in case anyone does something like this ...

However, in a welcome world, the app still happens. I've tried with and without FastClick, but Fastclick didn't work as expected (possibly a conflict with jQuery Mobile, arrghh).

+3


source to share


1 answer


your problem is most likely caused by using onclick event to trigger childbrowser.

onclick has a built-in 300ms timeout which can make the application look laggy and cause some of the problems above.



Use mouseup / mousedown instead and inside the handler, disable the listener

<a href="#" onclick="open('http://www.google.com','_blank')">OPEN WINDOW</a>

function open(url, name) {
    // deregister the onclick listener, insuring the callback resolves
    window.open(url,name);
    // register the listener
}

      

0


source







All Articles