views:

98

answers:

2
+1  Q: 

Open new tab in IE

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

ProcessStartInfo startInfo = new ProcessStartInfo
{
  Arguments = "http://www.mysite.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 wich browser whant 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 exemple: if he choosed 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 :)

+1  A: 

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?

Fiona Holder
+7  A: 

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 ;)

Øyvind Bråthen
+1 Opening in the user's default browser is highly recommended. As a power user I get highly annoyed when an application tries to launch IE for a site when I can launch Chrome in 1/2 the time and IMHO have a better browsing experience.
scunliffe
you're write, your solution works fine but what if the user doesn't want to use his default browser? how can i do it?
Gaby
As far as I know you can't, if not, as Fiona Holder wrote, IE has some command line parameter you can pass to it to give this functionality. And I doubt it, since that means that the instance of IE your trying to open has to see if another instance if open, send the URL to that instance and close itself.
Øyvind Bråthen
If you want to guarantee that you launch a new tab in an existing IE instance, you cannot do so by ShellExec'ing from the command line. You probably could do it by using the Navigate2 API with appropriate flags after having found an existing window in the ShellWindows collection. Because of the integrity level challenge, this would not be simple.
EricLaw -MSFT-
Thanks EricLaw -MSFT, it is working i only have to give the navigate2(myUrl,2048,...), 2048 to open new tab.PLease posted as an answer to mark it as write answer :) Btw now i want to make same work with fireFox and GoogleChrome, do you have any ideas??
Gaby
If you want to do this per browser, I really don't understand the reasoning. I thought that you maybe had some IE specific functionality and therefore needed to open it in IE only. But if it's supposed to work for many browsers, why not just take the default browser for the user? This promise this will annoy a shitload of users :)
Øyvind Bråthen
Hi Øyvind Bråthen, Sorry man i think that it is my fault because i'm not good in english and i can't explain exactly what i need, but i'll try. Please look to my edited question :)
Gaby