Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript code to force html page to open in Chrome browser?

We are using Google Apps at our company and everyone has Chrome installed on their computers. The problem is that we still have to use IE for certain things. I have a few html files on our intranet site that link to Google Docs, but it's opening in an IE browser. I need it to open a Chrome browser so the user doesn't have to sign in each time they open the file. I only have control of the html files settings so is there any way to use Javascript to force a window to open in Chrome?

Thanks!

like image 323
Megan Avatar asked Mar 15 '12 15:03

Megan


People also ask

How do I change the HTML to open in Chrome?

Find the HTML file you want to view, right-click on it, and choose Open with from the menu. You will see a full list of apps that you can use to run your file. Your default browser will be at the top of the list. Select Google Chrome from the list, and view your file in the browser.

How do I force Chrome to open a web page?

Open Specific Sites in ChromeLaunch Google Chrome, click on the Wrench menu and select Settings. Under On Startup section, select Open a Specific Page or Set of Pages. Click on Set Pages button. This includes websites that you want to open at Google Chrome startup.


1 Answers

I believe that if you're using IE you can use ActiveX to open up specific programs.

For instance try looking at 'new ActiveXObject'

You must explicitly allow this however as IE confirms if you want to allow it to be executed.

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

If you know the direct file path use this like

loadProg(path);

More specifically like

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

I don't know the path to Chrome so i used something else instead.

like image 111
AlanFoster Avatar answered Oct 01 '22 19:10

AlanFoster