-
WebBrowser anchor tags
In the .DocumentCompleted event of a WebBrowser I call a function. This function goes through the WebBrowser.DocumentText looking for a string and places an anchor around it(<a name="newanchor">asdf</a>). The first anchor is tagged "newanchor0", the next "newanchor1" and so on. When it is through, it sets WebBrowser.Document.Body.InnerHtml to the new string it has created. Finally, it scrolls to a newly created anchor with this:
WebBrowser.Navigate(WebBrowser.Url.ToString & "#newanchor" & rnd.Next Mod iNumAnchors)
I only used a random(rnd is a Random) anchor to be sure that it could actually jump to any anchor I had created. This works. Calling this function several times snaps me to a new random anchor. I've also found that I can Navigate to several anchors at the end of that function, obviously stopping on the last one called. However, when the function is finished, it goes back to .DocumentCompleted and then exits that Event.
After that, my anchors don't work. I navigate(via "Next" and "Prev" buttons) using the exact same code and I get nothing. It is as if after .DocumentCompleted the anchors don't persist.
Any ideas?
Thanks