1. Home
  2. Computing & Technology
  3. Visual Basic

Open a Web Document at a Specific Location
Process.Start won't open a location in a web document. WebBrowser.Navigate will.

By Dan Mabbutt, About.com

An About Visual Basic reader asked for help with this problem where the VB.NET statement ... Process.Start("file:///C:/mainpage.htm#detailpage.htm") ... would only open the mainpage.htm. They wanted to open the detail page instead and nothing they tried would do it. My friend noted that when URI ...

C:/mainpage.htm#detailpage.htm

... by itself was entered into the address field of the browser, everything worked as it should. (The characters following the "#" in the URI are called a "fragment", also known as a "ref" or a "reference" in the web world.)

Microsoft would probably answer this problem with their dry, catchall response: "The behavior is by design." Out here in the real world where we're trying to use their products, we translate that into, "It's not a bug! It's a feature!"

The Process.Start method is documented here at About Visual Basic in a different article. You can read all about Process.Start by clicking here.

Unfortunately, I don't know of a way to use Process.Start to open the fragment URI because Process.Start will only pass a "file" in this context. And a fragment is technically not part of a file name. Process.Start actually "cleans up" the file name by deleting any extraneous information before passing it to Windows. That's why it's a "feature"!

You can do what the reader wants ... sort of. The WebBrowser component will accept a URI (not a file) so you can add that component to a VB.NET application and code it this way:

WebBrowser1.Navigate("file:///C:/mainpage.htm#detailpage.htm")

Then it works like a shot. But the web page is contained within the WebBrowser component pane. It doesn't run as an independent process in Windows this way.

More Visual Basic Quick Tips
Explore Visual Basic
By Category
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Quick Tips
  5. Opening a specific location in a web document

©2009 About.com, a part of The New York Times Company.

All rights reserved.