Using webbrowser activex object, cannot get bookmarks within page to work if bookmark has space in the name


I am using the MS Web Browser activex object in a form to display context sensitive help.

If I pass a URL using Navigate such as "c:\page.htm#bookmark", it works fine.  However if there is space in the bookmark name ("c:\page.htm#book mark") it doesn't, although the name is valid and exists in the page and works if you type the url direct into an IE address bar.  All it does is display the page starting at the top.

I've tried replacing the space with %20, but still no joy.

Using Windows 2000 Server, Access 2000, IE6

Any thoughts?
rgke001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dqmqCommented:
Just a hunch, try putting bookmark path in double-quotes.  If already in quotes then, try triple-double, i.e.
"""c:\page.htm#book mark"""

0
GRayLCommented:
Try:

'c:\page.htm#bookmark'
0
harfangCommented:
YABOMS!

True bug. This seems to be caused by a defective internal threading mechanism. An anchor containing a space is recognized only once the HTML containing has been loaded (that is true for all anchors) but the URL parser does not wait for the load to complete. It does if there is no space...
But it could be anything else, and this is not open source ;)

I couldn't find a good fix, so here is a workaround:

    strURL = "file:///c:/page.htm#book mark"
    With Me.acxBrowser.Object

        ' normal navigation (creates the Document object)
        .Navigate strURL
       
        ' YABOMS: doesn't find bookmarks with spaces!
        ' need a workaround...
       
        ' wait for up to 5 seconds while browser is busy
        sngStamp = Timer()
        Do   ' at least one DoEvents is needed for this to work
            DoEvents
        Loop While .Busy _
        And sngStamp <= Timer() And Timer() < sngStamp + 5

        ' reset document's URL now that the full page is loaded
        .Document.URL = strURL

    End With

Good luck!
(°v°)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgke001Author Commented:
Fantastic - how do you figure out all this stuff??
Thanks.
0
harfangCommented:
Frankly? I didn't believe you and tried it for myself ;)

Then I was hooked and tried other navigations methods, until one worked. The "explanation" is pure guesswork, but this _is_ a bug, no doubt about it.

Anyway, I'm glad you like this workaround. happy automated browsing!
(°v°)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.