• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

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?
0
rgke001
Asked:
rgke001
1 Solution
 
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
 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now