0

I am trying to start a custom protocol handler in Chrome via Javascript. I can get the app to start but to do so creates a popup window which then triggers a pop-up blocker. Is there anyway to start the app without a pop-up window? The window closes but it is still considered a pop-up.

This is my current code:

    function setBrowser() {
        var userAgent = navigator.userAgent.toLowerCase();
        if (userAgent.indexOf("chrome") > -1) {
            //If Chrome launch without ActiveX involved
            var url = 'ABCProcessLaunch:-Domain mydomain -Args http://google.com -requirelogin true -method "chrome"';            
            setTimeout(window.close, 10);
            window.open(url, '_blank');
        }
    }
pldiguanaman
  • 125
  • 1
  • 9
  • Duplicate of [Close browser window after opening Custom Protocol](https://stackoverflow.com/questions/17545430/close-browser-window-after-opening-custom-protocol) – esqew Aug 25 '21 at 18:10

1 Answers1

0

I'm inferring from your call to window.close that this is likely why you need to open the link in a new window in the first place.

You may have some luck with opening the custom URL scheme in an <iframe> element instead. That way, your setTimeout call will still be triggered after 10 seconds:

function setBrowser() {
    var userAgent = navigator.userAgent.toLowerCase();
    if (userAgent.indexOf("chrome") > -1) {
        //If Chrome launch without ActiveX involved
        var url = 'ABCProcessLaunch:-Domain mydomain -Args http://google.com -requirelogin true -method "chrome"';   
        var iframe = document.createElement("iframe");
        iframe.src = url;         
        setTimeout(window.close, 10);
        document.querySelector("body").appendChild(iframe);
    }
}
esqew
  • 42,425
  • 27
  • 92
  • 132
  • I tried that method. It still gets blocked as being a "pop-up" If I allow the site then both methods work, I was trying to find a method that would avoid needing to add to allowed sites in Chrome. – pldiguanaman Aug 25 '21 at 19:28