问题
Even though IE is our default browser we want users to open links from email notifications in Firefox.
So I tried:
<a href="file:///C:\Program Files (x86)\Mozilla Firefox\firefox.exe">Click me!</a>
which works just fine, but when I try to pass the URL onto it it doesn't:
<a href="file:///C:\Program Files (x86)\Mozilla Firefox\firefox.exe google.com">Click me!</a>
What am I missing?
回答1:
From a URL, you can't target a specific browser. That's a client preference and not something that you can specify in a URI.
BTW, the file://
scheme is simply to allow you to open local resources in browsers, and cannot execute applications. Picture clicking on:
<a href="file:///C:/Windows/System32/command.com+%2Fc+"format+C:+/Q"">Click me, I'm cool!</a>
If you want that kind of control, you'd have to implement (and roll out) your own schema mechanism. i.e. making firefox://http/somesite.com/foo/bar.htm
bind to using Firefox specifically.
回答2:
You probably can try to do this via the VBScript usage of WShell, granted client's security settings allow launching ActiveXs in that zone. However, that obviously limits you to IE as a browser from within which you can perform the action.
来源:https://stackoverflow.com/questions/29511891/how-to-open-a-specific-url-in-a-specific-browser-from-a-link