0

Background

We are developing an application where you can search some stuff on the internet or open a webpage and you can chose what browser to use as well.

So if I would like to open Google.com for example, and I want it to open in Chrome, then the webpage should open in Chrome. In the event that I want to open Google.com in IE, then IE should open the Google page.

Now about using a tab in the browser: since all browsers now support it, opening a webpage in a new tab is already taken care of by the browser itself, whether it be Chrome or Firefox. But in the case of IE, if IE is your default browser, then IE will open the webpage in a new IE tab. However, if IE is not your default browser, then IE will instead open the web page in a new IE window.

Some additional information

There are several ways of opening a web page via: code for your default web browser

Process.Start(new ProcessStartInfo() { FileName = "http://www.google.com" }); 

or if you want to open the webpage in another webbrowser besides the default one. Firefox for example

string a = "%programfiles%\\Mozilla Firefox\firefox.exe"; a = Environment.ExpandEnvironmentVariables(a); Process.Start(new ProcessStartInfo() { FileName = a, Arguments = "http:\\www.google.com" }); 

command

>start "http://www.google.com" 

or

cmd /c start "http://www.gooogle.com"

Question

How do you open a webpage in IE(for version 8, 9, and 10) on a new tab even if IE is not your default browser?

3
  • Assuming that firefox will be located at "%programfiles%\\Mozilla Firefox\firefox.exe" isn't a great idea. Commented Jun 13, 2013 at 1:58
  • 1
    Duplicate question of stackoverflow.com/questions/3713206/… Commented Jun 13, 2013 at 2:20
  • @RobertMcKee - Thanks! looks like a another bright day waiting Commented Jun 13, 2013 at 5:27

2 Answers 2

2

Windows understands shorthand for any entries in the registry here:

HKEY_LOCAL_MACHINE SOFTWARE Microsoft Windows CurrentVersion App Paths 

So, assuming the browser installs happened without issues, each client will have entries such as:

  • Firefox.exe
  • IEXPLORE.exe
  • Chrome.exe

Which means, you can actually use this sort of thing:

Process.Start(new ProcessStartInfo() { FileName = "firefox.exe", Arguments = " \"http://www.google.com\"" }); Process.Start(new ProcessStartInfo() { FileName = "iexplore.exe", Arguments = " \"http://www.google.com\"" }); Process.Start(new ProcessStartInfo() { FileName = "chrome.exe", Arguments = " \"http://www.google.com\"" }); 

.. thereby targeting a specific browser.

Sign up to request clarification or add additional context in comments.

Comments

1

If it is intended that you are fixed on using Internet Explorer for this, this is what you can do:

Create a (temporary) script file called temp.js. Put this in it:

var navOpenInBackgroundTab = 0x1000; var objIE = new ActiveXObject("InternetExplorer.Application"); objIE.Navigate2(FIRST TAB URL GOES HERE); objIE.Navigate2(SECOND TAB URL GOES HERE, navOpenInBackgroundTab); objIE.Navigate2(NTH TAB URL GOES HERE, navOpenInBackgroundTab); objIE.Visible = true; 

Then you call this script in the directory you created it: wscript temp.js

Don't forget to delete it afterwards:

Oh, and if this sounds like a terrible hack, trust me: it is.

1 Comment

solution looks insecure but looks helpful. I'll give it a try

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.