3

I have one application which default open in IE browser. On the home page, there is link. if we click that link, application open in another tab of IE but I want to change the browser also.

<!DOCTYPE html>
<html>
<body>

<p>Open link in a chrome browser <a href="https://www.dotnet-tutorial.com" target="_blank">Visit Dotnet Tutorial</a></p>

</body>
</html>

If I click on Visit Dotnet Tutorial, it should open in chrome. How to setup browser also in Hyperlink.

Please help on this. thanks

Mukesh Kumar
  • 2,354
  • 4
  • 26
  • 37

3 Answers3

3

Place this code in between head tag.

<script type="text/javascript">
   
    function openURL() 
    {
         var shell = new ActiveXObject("WScript.Shell");
         shell.run("Chrome https://google.com");
    }                 
</script>

and use anchor tag like this.

<a href="#" title="your wish" onclick="openURL()">
TylerH
  • 20,799
  • 66
  • 75
  • 101
  • Helped me after 7 yrs. Thank you. If you don't want to add chrome to the OS path environment variable use shell.run("\"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\" "); – Meeting Attender Dec 10 '18 at 13:18
0

This is not possible from the HTML.
Browser is chosen based on the Operating System settings.

Yours is obviously IE.

If you own the dotnet-tutorial page, you can set up a browser check there and add a notification like: "This page works best in Google Chrome"

This question explains how to detect browser: How to detect Safari, Chrome, IE, Firefox and Opera browser?

tripleee
  • 175,061
  • 34
  • 275
  • 318
d.raev
  • 9,216
  • 8
  • 58
  • 79
0

Extension to Ajay's answers if ActiveX - Automation Server Can't Create Object and link doesnot open in chrome please follow this steps: a) Go to Tools-->Internet Options

b) Select security tab

c) Click on Trusted Sites (or Local Intranet depending on whether your site is trusted or not)

d) Click on Custom Level

e) Ensure that "Initialize and script active x controls is not marked safe for scripting" is enabled - this comes under Activex controls and plug-ins section towards 1/4th of the scroll bar.

Click OK, OK.

Once this is completed, clear the browser cookies and cache. Close all your browser sessions. Reopen the IE to launch your site.

mohan
  • 21
  • 2