Question

Windows 8.1 / IE 11 custom url protocols are messed up. Upon launch, the application is executed and then the url in the browser redirects to about:blank

Even Skype's protocol does it:

<a href="skype:_some_skype_account_here_?chat">Chat via Skype</a>

I've tried a handful of approaches such as using an iframes, document.location.href = u; with poor results.

This appears to work when the link is inside of an iframe, yet fails otherwise:

 <a href="javascript:'x();'>test</a>  
 document.location.href = 'proto://datadatadata';

Anyone know how to launch the protocol's app without the browser redirecting to about:blank?

I am now treating IE11 as a completely different browser: chrome, FF, safari, IE7-10 and IE11

Was it helpful?

Solution

This version appears to be working:

var iframe = document.createElement('IFRAME');
iframe.setAttribute('id' 'protoIframe');
iframe.setAttribute('src', 'myapp://datadatadata' );
iframe.style.display = 'none'; 
iframe.style.width   = 1+'px'; 
iframe.style.height  = 1+'px'; 
document.documentElement.appendChild(iframe);

UPDATE: (months afterwards)

This is the final version I've been using for IE. I detect the browser and if IE then do:

var hst = { pad:'--eof--'}

hst.forIE = function(service, data) {
    var f = document.getElementById('ecPrinterIframe')
    if (f ) 
        f.parentNode.removeChild(f);
    var iframe = document.createElement('IFRAME');
    iframe.setAttribute('id',    'ecPrinterIframe');
    iframe.setAttribute('src', 'myproto://' + data + hst.pad );
    iframe.style.display    = 'none'; 
    iframe.style.width      = 1+'px'; 
    iframe.style.height     = 1+'px'; 
    document.documentElement.appendChild(iframe);
}    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top