How to format a link to open in Chrome instead of IE?

Is it possible to force a link within a SharePoint site to open in a certain browser?

We have an online system that works best in Chrome. I've placed a link to this system in a library on our site - however, it will open in IE if that happens to be your default browser.

Ideally, a user would click the link and it would open in Chrome, no matter what his/her default browser is.

Someone asked this question on another forum and was given this answer:

OOTB, SharePoint only opens in browser which is set as default.

However, if this customization is absolutely necessary,you can develop a server side web part in which you can generate a link.Clicking on which will execute Chrome.exe process and open the link in browser.

Code snippet to call Chrome.exe would be as follows:

System.Diagnostics.Process.Start("chrome.exe", "http://sp.path.to/your/file.doc")

My issue is that I don't know much code, where to place this code, or how to make it execute when a link is clicked. Can anyone give me a push in the right direction?

FYI: Here's the link to the other forum where this question was asked. I can't place a hyperlink in the body of this question b/c my account is not yet verified: sharepoint.stackexchange.com/questions/132858/format-link-to-open-in-desired-browser-chrome

February 26th, 2015 11:01pm

Thanks Ganesh for your answer!

I do have a few questions. For your first block of code - is this something I would place inside the HTML source for the webpart? For example, would I place it inside the HTML source for my link library?

For your second block of code - where do I place this?

Thank you!

Free Windows Admin Tool Kit Click here and download it now
February 27th, 2015 8:52am

In your webpart,  you can add a linkbutton and on buttonclick event of that you can launch crome.

you can please try -

using (var process = new Process()) { process.StartInfo.FileName = @"C:\Users\<UserName>\AppData\Local\Google\Chrome\chrome.exe"; process.StartInfo.Arguments = "your url"; process.Start(); }


for current user appdata folder path , you can try -

var cromePath = Path.Combine(Environment.GetFolderPath(
    Environment.SpecialFolder.ApplicationData), "\Local\Google\Chrome\chrome.exe")

//C:\Users\<UserName>\AppData\Local\Google\Chrome\chrome.exe

February 27th, 2015 1:57pm

Hi,

This is server side code , you should write in your C# code behind method for Click event of Link Button .

- Use 1st part code in your button event handler method. (Replace <username> with current user name), best way is to find the crome.exe location at your dev machine , and paste the path here - process.StartInfo.FileName = @""; , default location is in user's appdata folder. Test the code.

- If the above code works , and if your crome.exe is in user's appdata folder , then you will need to find dynamic location of AppData folder for every user. That means the path should not be hard coded. The 2nd part of the code is an hint for how you can find the appdata path in C#. Something like this

//var cromePath = @"C:\Users\<UserName>\AppData\Local\Google\Chrome\chrome.exe";  

var cromePath = Path.Combine(Environment.GetFolderPath(
    Environment.SpecialFolder.ApplicationData), "\Local\Google\Chrome\chrome.exe");

using (var process = new Process())
{
    process.StartInfo.FileName = cromePath;
    process.StartInfo.Arguments = "your url";
    process.Start();
}

So the step will be

- First try a direct call to crome,

var cromePath = @"crome.exe";

- if it not works , then try with hardcoded path of crome.exe from your dev machine for current user -

var cromePath = @"C:\Users\<currentUserName>\AppData\Local\Google\Chrome\chrome.exe";

- And if this work , then try it with dynamic path for any user, find appdata folder location through code 

var cromePath = Path.Combine(Environment.GetFolderPath(
    Environment.SpecialFolder.ApplicationData), "\Local\Google\Chrome\chrome.exe");

Hope this will help, if you are a C# developer then you can easily understand  the concept.

Free Windows Admin Tool Kit Click here and download it now
February 28th, 2015 2:55am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics