I can't get my C# program to open the html page at the desired location.

E.g.

System.Diagnostics.Process.Start(@"C:\file.htm");

works fine. It opens the page at the top.

But if I type

System.Diagnostics.Process.Start(@"C:\file.htm#bookmark");

it still just opens at the top of the page (instead of at the bookmark where I want it to open.

Any ideas?

I've noticed that even if you save a shortcut to an HTML FILE to your desktop, it strips off the bookmark before it saves. The bookmark code interferes with the filename.
So, something like:
file:///C:/Documents%20and%20Settings/mememe/Desktop/fred.htm#bookmark2
becomes:
file:///C:/Documents%20and%20Settings/mememe/Desktop/fred.htm
when saved.

You *can* however, create a second page (let's say Joe.htm) that has some relocation javascript in it that sends you to fred WITH THE BOOKMARK!

Contents of Joe.htm

<script language="javascript">
 window.location.href="file:///C:/Documents%20and%20Settings/mememe/Desktop/fred.htm#bookmark2";
</script>

When it opens, it will load Fred.htm and navigate to the bookmark.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.