Trying to open a link in IE window from Chrome browser

落花浮王杯 提交于 2020-01-25 11:21:08

问题


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.


回答1:


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.




回答2:


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.


来源:https://stackoverflow.com/questions/53123872/trying-to-open-a-link-in-ie-window-from-chrome-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!