简体   繁体   中英

Trying to open a link in IE window from Chrome browser

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM