Answered by:
How can we force a link to open a URL in a different browser?

Question
-
User820687296 posted
How can we force a link to open a URL in a different browser?
e.g. A link in IE webpage to be open in Google Chrome window.
is it possible?
Friday, February 11, 2011 1:25 AM
Answers
-
User1844282159 posted
I'm not sure if this is what you are looking for but I tried the below code and was able to force a link from my IE browser to open in FireFox.
I got the original source from here: http://stackoverflow.com/questions/185423/how-can-i-open-a-link-in-the-default-web-browser-from-an-hta
I slightly amended the source to specifically tell the shell command to open the url in Firefox.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <title>HTA Test</title> <hta:application applicationname="HTA Test" scroll="yes" singleinstance="yes"> <script type="text/javascript"> function openURL() { var shell = new ActiveXObject("WScript.Shell"); shell.run("Firefox http://www.google.com"); } </script> </head> <body> <input type="button" onclick="openURL()" value="Open Google in Firefox"> </body> </html>
I'm sure you can replace the browser name with a variable or you can even generate the Javascript in code-behind with the required values and inject it through the RegisterStartupScript method of the ClientScriptManager.
More information on the use of the HTA:Application Object: http://msdn.microsoft.com/en-us/library/ms536495%28v=VS.85%29.aspx
Hope this helped.
Kind Regards,
Francois
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, February 11, 2011 7:04 AM
All replies
-
User236141260 posted
You can open same new browser by setting property target="_new" , but you cant open it in different browser.
Friday, February 11, 2011 1:34 AM -
User820687296 posted
well that was pretty simple but the requirement is different here.
Friday, February 11, 2011 1:38 AM -
User-1171043462 posted
You will need to open popup window using javascript
Friday, February 11, 2011 2:21 AM -
User820687296 posted
I don't think your answer relates to my question.
Anyway i have seen what you have written there ;)
Friday, February 11, 2011 2:39 AM -
User-1171043462 posted
I don't think your answer relates to my question.
Anyway i have seen what you have written there ;)
Yes. I missed it. But I would say what you are trying to do is impossible as the browsers have very limited access to client's machine.
Hence neither they can open in some other browser nor find out which browsers are installed
Friday, February 11, 2011 4:35 AM -
User-1859169499 posted
How can we force a link to open a URL in a different browser?
e.g. A link in IE webpage to be open in Google Chrome window.
is it possible?
No.
Friday, February 11, 2011 5:51 AM -
User1844282159 posted
I'm not sure if this is what you are looking for but I tried the below code and was able to force a link from my IE browser to open in FireFox.
I got the original source from here: http://stackoverflow.com/questions/185423/how-can-i-open-a-link-in-the-default-web-browser-from-an-hta
I slightly amended the source to specifically tell the shell command to open the url in Firefox.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <title>HTA Test</title> <hta:application applicationname="HTA Test" scroll="yes" singleinstance="yes"> <script type="text/javascript"> function openURL() { var shell = new ActiveXObject("WScript.Shell"); shell.run("Firefox http://www.google.com"); } </script> </head> <body> <input type="button" onclick="openURL()" value="Open Google in Firefox"> </body> </html>
I'm sure you can replace the browser name with a variable or you can even generate the Javascript in code-behind with the required values and inject it through the RegisterStartupScript method of the ClientScriptManager.
More information on the use of the HTA:Application Object: http://msdn.microsoft.com/en-us/library/ms536495%28v=VS.85%29.aspx
Hope this helped.
Kind Regards,
Francois
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, February 11, 2011 7:04 AM -
User-1011137159 posted
There are many way to achieve this.
1. By JAva script we can achieve this by below code.
window.open('Mypage.aspx','My Page',500,500)
Another way is assign target="_new" at your link controls attribure then also it open in new page.Friday, February 11, 2011 7:09 AM -
User820687296 posted
Thanks fwahl that worked.
Friday, February 11, 2011 10:16 AM -
User260690746 posted
Thanks also FWAHL. I couldnt find nothing like that and was thinking it was imposible. It worked for me too.
Friday, February 11, 2011 1:38 PM