1

I have seen this question been asked here Can I force a link to open in a specific browser?

I found one solution which works eg.

window.open("microsoft-edge:https://www.google.com");

This works for Edge but I am looking for similar solution to open in Internet Explorer.

Tried
ie, iexplore, internet-explorer

Also i cant depend on users installing 'open in' extension in their browser.

I could possibly go down the route of editing registry since webapp will be running in corporate systems , but just wanted to check here before going down that route.

Murtaza Haji
  • 1,093
  • 1
  • 13
  • 32

2 Answers2

3

It looks like IE does not register itself as a URI scheme.

In order for an application (a browser in this case) to listen to a URI-scheme, it needs to be registered in the Registry (for Windows at least). I just ran a small script listing all the registered URI schemes and unlike Edge, I don't see anything that represents Internet Explorer. (I do have it installed).

Of course, the best way would be to avoid Internet Explorer completely since it is deprecated. But if you do stick with it, editing the registry yourself seems the only option.

Ivar
  • 6,138
  • 12
  • 49
  • 61
  • 1
    Yes i will be following this example. https://stackoverflow.com/questions/40531374/open-internet-explorer-from-chrome-using-a-protocol-handler-ieurl/41749105#41749105 I just didnt want to go through this hassle since ill have to raise a request to system admin to make this protocol available on all systems. – Murtaza Haji Nov 02 '18 at 19:39
  • Some legacy sites only runs in IE, so you just can't avoid it. – CDT May 17 '19 at 01:44
  • @CDT At some point IE will no longer receive any security updates at which point it will be completely irresponsible to require users to use it. If someone wants to add an IE URI scheme to their URL's they likely have access to the source code of the application in which case it would be way better to simply make it work for other browsers as well. Not to mention that in order to achieve this, you need access to the user's PC as well to modify the registry, which in many cases isn't the case. – Ivar May 18 '19 at 08:53
0

Simplest solution would be add a URI scheme for IE, and links in format ie:http://example.com will launch IE and visit http://example.com.

To add a URI scheme for IE, add this registry:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\ie]
"URL Protocol"=""
@="URL:IE Protocol"

[HKEY_CURRENT_USER\Software\Classes\ie\shell]

[HKEY_CURRENT_USER\Software\Classes\ie\shell\open]

[HKEY_CURRENT_USER\Software\Classes\ie\shell\open\command]
@="cmd /c set url=\"%1\" & call set url=%%url:ie:=%% & call start iexplore -nosessionmerging -noframemerging %%url%%"

Some important notes:

  1. You have to wrap %1 in double quotes. Otherwise url with multiple params like example.com?a=1&b=2 will be stripped to example.com?a=1, params after & will be ignored.
  2. You have to remove the double quotes when calling iexplore. If you don't remove the double quotes and open multiple IE window from chrome, only the first IE window will get the correct URL. But removing quotes with command set url=%%url:\"=%% or set url=%%url:~1,-1%% doesn't work.
  3. If you just can't make it to remove those quotes, add switches -nosessionmerging and -noframemerging to iexplore. These are command-line options to control "merging" behavior for IE.
CDT
  • 10,165
  • 18
  • 66
  • 97