Javascript code to open html page in chrome browser?

We use Google Apps in our company, and each Chrome is installed on our computers. The problem is that we still have to use IE for certain things. I have several html files on our intranet site that link to Google Docs, but they open in IE browser. I need it to open the Chrome browser, so the user does not need to sign up every time the file is opened. I only control the settings of the html files, so is there a way to use Javascript to make the window open in Chrome?

Thanks!

+6
source share
4 answers

I believe that if you use IE, you can use ActiveX to open certain programs.

For example, try looking at the "new ActiveXObject"

You must explicitly allow this, as IE confirms whether you want to allow its execution.

function loadProg(path){ var active = new ActiveXObject("WScript.Shell"); activeX = active.Run(path); } 

If you know the direct file path uses this, for example

 loadProg(path); 

More specifically, how

 window.onload = function(){ loadProg("\"C:\\Program Files (x86)\\Guitar Pro 5\\GP5.exe\""); }; 

I don’t know the path to Chrome, so instead I used something else.

+4
source

You ask if you can open a Chrome window from Javascript in an IE window? If so, then no, it is not possible. Javascript code in browsers works in a very strict sandbox, which will not allow you to make any system calls. Opening a Chrome window from IE would actually require chrome.exe to chrome.exe on the client machine. I am sure that you can see how this ability, if provided, can be used incorrectly to execute a malicious exe on the client system.

-1
source

Check if the current browser is chrome:

 var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1; 

if not, inform the user about the message.

-1
source

I’m absolutely sure that the best thing you can do with JavaScript is to show the user a message and tell them to open the file in Chrome. JavaScript is not allowed to execute an external application such as Chrome. See http://www.w3schools.com/js/js_browser.asp for information on detecting a browser using JavaScript.

-1
source

Source: https://habr.com/ru/post/910816/


All Articles