2

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

Brian McGinity
  • 5,777
  • 5
  • 36
  • 46

1 Answers1

3

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);
}    
ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Brian McGinity
  • 5,777
  • 5
  • 36
  • 46
  • Hm, I also have problems running my custom URL protocol in IE 11 + Win 7 SP1. When I run it in IE 11 + Win 8.1, it runs just well. Also on other systems. I find it weird. I will try this solution. – swdev Jul 06 '14 at 23:04
  • 1
    @swdev I just updated the post with the version I've been using in production. This is working in IE11 Win 7 -- I just double checked. Hope this works for you too. I am calling a js function which calls the above function as: Print Tag – Brian McGinity Jul 06 '14 at 23:37
  • Splendid. Will give this a try! – swdev Jul 06 '14 at 23:38
  • I am still in the process of updating Win 7 to SP1 and installing IE 11, right now I am reading this article : http://blogs.msdn.com/b/ieinternals/archive/2011/07/14/url-protocols-application-protocols-and-asynchronous-pluggable-protocols-oh-my.aspx Have you read it also? It seems like I really have to do client side solution as yours. – swdev Jul 08 '14 at 14:22
  • UPDATE: Just solve this case using your solution. In my particular case, my custom URL protocol is very long (more than 535 characters, maximum allowed by IE --tested it myself). After moving the regular hyperlink into a javascript that create `iframe`, it works! Thanks @Brian! – swdev Jul 16 '14 at 06:18