问题
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.
Triedie
, 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:
- You have to wrap
%1
in double quotes. Otherwise url with multiple params likeexample.com?a=1&b=2
will be stripped toexample.com?a=1
, params after&
will be ignored. - 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 commandset url=%%url:\"=%%
orset url=%%url:~1,-1%%
doesn't work. - If you just can't make it to remove those quotes, add switches
-nosessionmerging
and-noframemerging
toiexplore
. 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