Danel Ceresa
Danel Ceresa

Reputation: 340

Hidden cordova inAppBrowser has no event for shown status

The cordova inAppBrowser has the next option on opening (as mentioned in https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/):

hidden: set to yes to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to no (default) to have the browser open and load normally.

The problem is that I want to detect and execute code when the browser is completely rendered on the screen of the device. The api provides "loadstop" event, but it's executed before the device's screen is showing the web page.

Is there any way to detect this moment?

EDITED:

This is what I'm trying (not exactly but similar):

inappService.runScript( 
    function (params) { 
        function handleVisibilityChange() {
            if (!document.hidden) {
                $('input#otp')[0].focus(); 
            }
        }
    document.addEventListener('visibilitychange', handleVisibilityChange, false); 
);

But "visibilitychange" occurs when the page is preloaded hidden. Any idea of how I could detect it with javascript on the web page? Thanks!!!

Upvotes: 2

Views: 530

Answers (1)

Racil Hilan
Racil Hilan

Reputation: 25361

The inAppBrowser has no event for when the it completely renders the page. However, you can try using its executeScript() method which allows to inject your own JavaScript. That allows you to use whatever technique you like for detecting the complete rendering of the page.

Upvotes: 1

Related Questions