setImmediate()

in src/windows/InAppBrowserProxy.js [139:297]


        setImmediate(function () {
            var strUrl = args[0];
            var target = args[1];
            var features = args[2];
            var url;

            navigationEventsCallback = win;

            if (target === '_system') {
                url = new Windows.Foundation.Uri(strUrl);
                Windows.System.Launcher.launchUriAsync(url);
            } else if (target === '_self' || !target) {
                window.location = strUrl;
            } else {
                // "_blank" or anything else
                if (!browserWrap) {
                    var browserWrapStyle = document.createElement('link');
                    browserWrapStyle.rel = 'stylesheet';
                    browserWrapStyle.type = 'text/css';
                    browserWrapStyle.href = urlutil.makeAbsolute('/www/css/inappbrowser.css');

                    document.head.appendChild(browserWrapStyle);

                    browserWrap = document.createElement('div');
                    browserWrap.className = 'inAppBrowserWrap';

                    if (features.indexOf('fullscreen=yes') > -1) {
                        browserWrap.classList.add('inAppBrowserWrapFullscreen');
                    }

                    // Save body overflow style to be able to reset it back later
                    bodyOverflowStyle = document.body.style.msOverflowStyle;

                    browserWrap.onclick = function () {
                        setTimeout(function () {
                            IAB.close(navigationEventsCallback);
                        }, 0);
                    };

                    document.body.appendChild(browserWrap);
                    // Hide scrollbars for the whole body while inappbrowser's window is open
                    document.body.style.msOverflowStyle = 'none';
                }

                if (features.indexOf('hidden=yes') !== -1) {
                    browserWrap.style.display = 'none';
                }

                popup = document.createElement(isWebViewAvailable ? 'x-ms-webview' : 'iframe');
                if (popup instanceof HTMLIFrameElement) {
                    // eslint-disable-line no-undef
                    // For iframe we need to override bacground color of parent element here
                    // otherwise pages without background color set will have transparent background
                    popup.style.backgroundColor = 'white';
                }
                popup.style.borderWidth = '0px';
                popup.style.width = '100%';
                popup.style.marginBottom = '-5px';

                browserWrap.appendChild(popup);

                var closeHandler = function (e) {
                    setTimeout(function () {
                        IAB.close(navigationEventsCallback);
                    }, 0);
                };

                if (features.indexOf('hardwareback=yes') > -1 || features.indexOf('hardwareback') === -1) {
                    hardwareBackCallback = function () {
                        if (browserWrap.style.display === 'none') {
                            // NOTE: backbutton handlers have to throw an exception in order to prevent
                            // returning 'true' inside cordova-js, which would mean that the event is handled by user.
                            // Throwing an exception means that the default/system navigation behavior will take place,
                            // which is to exit the app if the navigation stack is empty.
                            throw 'Exit the app'; // eslint-disable-line no-throw-literal
                        }

                        if (popup.canGoBack) {
                            popup.goBack();
                        } else {
                            closeHandler();
                        }
                    };
                } else if (features.indexOf('hardwareback=no') > -1) {
                    hardwareBackCallback = function () {
                        if (browserWrap.style.display === 'none') {
                            // See comment above
                            throw 'Exit the app'; // eslint-disable-line no-throw-literal
                        }

                        closeHandler();
                    };
                }

                document.addEventListener('backbutton', hardwareBackCallback, false);

                if (features.indexOf('location=yes') !== -1 || features.indexOf('location') === -1) {
                    popup.style.height = 'calc(100% - 70px)';

                    navigationButtonsDiv = document.createElement('div');
                    navigationButtonsDiv.className = 'inappbrowser-app-bar';
                    navigationButtonsDiv.onclick = function (e) {
                        e.cancelBubble = true;
                    };

                    navigationButtonsDivInner = document.createElement('div');
                    navigationButtonsDivInner.className = 'inappbrowser-app-bar-inner';
                    navigationButtonsDivInner.onclick = function (e) {
                        e.cancelBubble = true;
                    };

                    backButton = document.createElement('div');
                    backButton.innerText = 'back';
                    backButton.className = 'app-bar-action action-back';
                    backButton.addEventListener('click', function (e) {
                        if (popup.canGoBack) {
                            popup.goBack();
                        }
                    });

                    forwardButton = document.createElement('div');
                    forwardButton.innerText = 'forward';
                    forwardButton.className = 'app-bar-action action-forward';
                    forwardButton.addEventListener('click', function (e) {
                        if (popup.canGoForward) {
                            popup.goForward();
                        }
                    });

                    closeButton = document.createElement('div');
                    closeButton.innerText = 'close';
                    closeButton.className = 'app-bar-action action-close';
                    closeButton.addEventListener('click', closeHandler);

                    if (!isWebViewAvailable) {
                        // iframe navigation is not yet supported
                        backButton.setAttribute('disabled', 'true');
                        forwardButton.setAttribute('disabled', 'true');
                    }

                    navigationButtonsDivInner.appendChild(backButton);
                    navigationButtonsDivInner.appendChild(forwardButton);
                    navigationButtonsDivInner.appendChild(closeButton);
                    navigationButtonsDiv.appendChild(navigationButtonsDivInner);

                    browserWrap.appendChild(navigationButtonsDiv);
                } else {
                    popup.style.height = '100%';
                }

                // start listening for navigation events
                attachNavigationEvents(popup, navigationEventsCallback);

                if (isWebViewAvailable) {
                    strUrl = strUrl.replace('ms-appx://', 'ms-appx-web://');
                }
                popup.src = strUrl;
            }
        });