How to Force a Link to Open in a Specific Browser

Can I force a link to open in a specific browser?

I don't think you can open a IE window from firefox, but you can easily build a firefox plugin based on your activex using http://code.google.com/p/ff-activex-host/

Open a link in a specific browser

You can't force the client to launch a different browser like you're asking.

What I would suggest is to have your application test when it is launched to see if it is currently running in IE. If it isn't, it should issue an error message stating something like: "This application requires Internet Explorer. Please reopen in IE." Then have it stop there.

How to open a specific URL in a specific browser from a link?

From a URL, you can't target a specific browser. That's a client preference and not something that you can specify in a URI.

BTW, the file:// scheme is simply to allow you to open local resources in browsers, and cannot execute applications. Picture clicking on:

<a href="file:///C:/Windows/System32/command.com+%2Fc+"format+C:+/Q"">Click me, I'm cool!</a>

If you want that kind of control, you'd have to implement (and roll out) your own schema mechanism. i.e. making firefox://http/somesite.com/foo/bar.htm bind to using Firefox specifically.

In C#, how do you programmatically open a link with a specific browser?

Try this:

System.Diagnostics.Process.Start("Chrome.exe", "http://www.stackoverflow.com");//or firefox.exe

You might have exceptions if the browser is not configured correctly. So it is better to catch the exception like this:

try
{
System.Diagnostics.Process.Start("Chrome.exe", "http://www.stackoverflow.com");//or firefox.exe

}
catch(System.ComponentModel.Win32Exception noBrowser)
{
if (noBrowser.ErrorCode == -2147467259)
MessageBox.Show(noBrowser.Message);
}
catch (System.Exception other)
{
MessageBox.Show(other.Message);
}

Trying to open a link in IE window from Chrome browser

It looks like IE does not register itself as a URI scheme.

In order for an application (a browser in this case) to listen to a URI-scheme, it needs to be registered in the Registry (for Windows at least). I just ran a small script listing all the registered URI schemes and unlike Edge, I don't see anything that represents Internet Explorer. (I do have it installed).

Of course, the best way would be to avoid Internet Explorer completely since it is deprecated. But if you do stick with it, editing the registry yourself seems the only option.

Can I open a link in targeted/specific browser-tab?

I solved this by storing IDs of pre-opened tabs in an array.
and then updating those tabs URL on onBeforeRequest event

let slots = [false, false, false, false] //will populate with placeholder tabs.
let preventTabCreation = false //will be true once initial tabs are created..
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
let url = details.url
let tabNo;
let tab_id = details.tabId
if(!slots.includes(tab_id) && preventTabCreation) {
for(let i = 1; i < slots.length; i++) {
if(urlinarr(linkTabs[i-1], url)) {
tabNo = i;
}
}
chrome.tabs.remove(tab_id)
chrome.tabs.update(slots[tabNo], {url: url, active: true})
return {cancel: true}
}
},
{urls: ["<all_urls>"]},
["blocking"]);

for the first time to create the placeholder tabs using this code.

chrome.browserAction.onClicked.addListener(function() {
launch()
})

function launch() {
//using the first tab for google sheets. where the links to be opened are.
if (!slots[0]) {
chrome.tabs.create({
url: "https://docs.google.com/spreadsheets",
index: 0
}, function(data) {
slots[0] = data.id
startPreventingTabCreation()
})
}
for (let i = 1; i < slots.length; i++) {
if (!slots[i]) {
chrome.tabs.create({
url: chrome.extension.getURL('dummy.html'),
index: i
}, function(data) {
slots[i] = data.id
startPreventingTabCreation()
})
}
}
}

function startPreventingTabCreation() {
if (slots.every(x => x != false)) {
preventTabCreation = true
chrome.tabs.update(slots[0], {
active: true
})
}
}


Related Topics



Leave a reply



Submit