How to open a specific URL in a specific browser from a link?

柔情痞子 提交于 2019-11-28 04:31:37

问题


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+&quot;format+C:+/Q&quot;">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

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