How can I navigate to different web pages in the same MSIE window in VB.NET

I have some code that opens a new window, but I want to be able to edit the same one.

System.Diagnostics.Process.Start("iexplore.exe", "http://www.live.com")

      

+1


a source to share


4 answers


I'm not sure exactly, but getting the window handle you are interested in might be a good pointer to start with:

http://www.pocketpcdn.com/articles/dotnetcf_hwnd.html



And then examine separately what interop messages you can send in IE to change the url in the X tab

0


a source


In order of increasing difficulty and increasing control / power:

  • Send input text to your IE process. Alt-D to focus on the navigation bar, then the URL, then press ENTER.
  • Use MSAA to find the navigation bar and submit it as above.
  • Use MSAA to access the IHTMLDocument browser, and then programmatically control the browser with that and associated interfaces.


I don't know your exact scenario, but if you can host your own MSHTML instance or WebBrowser control, it makes it easier to get the interfaces and does the manipulations mentioned in # 3 above; doing this cross process is fraught with danger.

I just did a web search and included the WatiN tool , which seems to wrap a lot of this work; maybe it would be helpful for you.

0


a source


If you are using 2008 there is a function where you can create a second form and then add a Webbrowser control

then the page could be called

myForm.show

      

The page can then be changed with

Webbrowser1.Url = New Uri("http://www.google.com")

      

0


a source


Use the following code:

System.Diagnostics.Process.Start("http://www.live.com")

      

That is: don't call iexplore.exe

directly - just let the system know which browser to open by default.

This can lead to two types of behavior:

  • Or it opens a new tab in an existing Internet Explorer window,
  • or creates a new window.

The important point is that it depends on the preference, which can be controlled in the Internet Explorer application. If a new window opens, then this is a user-selected setting - don't try to override it: overriding user preferences is considered bad manners.

If users don't want to open a new window, they can simply change this in their Internet Explorer settings.

0


a source







All Articles