Gaby
Gaby

Reputation: 3033

Open new tab in IE

i'm using the following code to open site in internet explorer

ProcessStartInfo startInfo = new ProcessStartInfo
{
  Arguments = "http://www.example.com",
  FileName = "C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe",
  RedirectStandardInput = true,
  UseShellExecute = false
};
System.Diagnostics.Process process = System.Diagnostics.Process.Start(startInfo);

How can i open my site in a new tab not a new browser considering that there is a browser already opened???

Well,

We are Building an application where the user can use 2 options:

1-Using the default browser.

2- use one of the following browsers: IE,Google Chrome and Firefox (for now).

and after choosing which browser want to use in his application, he must choose if he want to open the requested page in a new window or in a new tab.

for example: if he choose IE with new tab option, so the system will try to find the last page opened by the program and refresh it if exist, and if not he will open it in a new tab.

Concerning the IE browser i think that EricLaw -MSFT helped me to found a way to open a new tab and a new window, i still have to know how can i get an opened tab (already opened by my program) and refresh in need.

I still have to do the same for Firefox and Google Chrome.

Thanks for your answers, and sorry again for my bad english :)

Upvotes: 3

Views: 9442

Answers (3)

Gokul
Gokul

Reputation: 831

reference Interop.SHDocVw.dll

 InternetExplorer ie = null;

 SHDocVw.ShellWindows allBrowser = new SHDocVw.ShellWindows();//gives all browsers
 int browserCount = allBrowser.Count - 1;//no . of browsers
 while (browserCount >= 0)
   {
     ie = allBrowser.Item(browserCount) as InternetExplorer;
     if (ie != null && ie.FullName.ToLower().Contains("iexplore.exe"))//all IE will have this name
       {
         ie.Navigate2("http://www.example.com", 0x1000);//0x1000 is the flag to open IE in new tab
         break;
       }
      browserCount--;

    }

Upvotes: 2

Øyvind Bråthen
Øyvind Bråthen

Reputation: 60684

You can simply use:

Process.Start("http://www.mysite.com");

This will not necessarily open in IE, but in the users default browser as a new tab (if the browser supports it) and that is probably what the user wants anyway ;)

Upvotes: 8

Unless iexplore.exe has some parameters that you can pass to it, I'm not sure if you can.

All the code you have is doing is launching a new IE process, so I can't see how it would be able to make use of a process that was already running.

Out of interest, if you know that there is already a browser running, why are you using this method for navigation?

Upvotes: 1

Related Questions