Launch a custom protocol handler using javascript in Chrome without a popup?

985 views Asked by At

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');
        }
    }
1

There are 1 answers

1
esqew On

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);
    }
}