Results 1 to 4 of 4

Thread: Webbrowser control click on file:// links does not work

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    244

    Webbrowser control click on file:// links does not work

    Is there a way to get a browsercontrol to actually do what IE does when a href="file://<mypath>" link is being clicked?

    well, it's with the following situation:
    Code:
        Call WebBrowser.Navigate("about:blank")
        Do While WebBrowser.ReadyState <> READYSTATE_COMPLETE
          DoEvents
        Loop
        If Not WebBrowser.Document Is Nothing Then
          Call WebBrowser.Document.write("<html><body><a href="file://C:/Windows/">C:\Windows</a><br><a href="http://www.google.com">google site</a></body></html>")
          Call WebBrowser.Document.Close
        End If
    It also seems not to work if I use Navigate to a local document with the same HTML..
    Opening the same page in IE and clicking on the link it will open the specified folder in windows explorer, and in chrome it will open the folder in chrome as a page..
    The weblink (http will work in all cases..

    I couldn't find anything on the subject in the webbrowser control tips & tricks thread, and using a search also didn't seem to find one that fits the bill..

    Or is the only way to get it to work, using the onclick event of the HTMLDocument, and parse all <a> and check if they are at the position of the mousecursor? (as in thread RESOLVED-How-to-get-URL-link-as-mouse-position-in-the-WebBrowser-control)

  2. #2
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Webbrowser control click on file:// links does not work

    Quote Originally Posted by SuperDre View Post
    It also seems not to work if I use Navigate to a local document with the same HTML..
    It works for me


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    244

    Re: Webbrowser control click on file:// links does not work

    Quote Originally Posted by jmsrickland View Post
    It works for me
    Hmm, I guess the navigate to a local document didn't work for me anymore because I had the htmldocument set to a variable withevents and I was trapping onclick (only trapping with nothing special). After I restored to the original code navigate did work, but that's not usable for me (as the file isn't stored locally but in memory (and no, I'm not gonna save it first to disc only for showing (see another thread for my reasons not to do it)).
    But thanx for testing the navigate one, as I also thought that should have worked, but during testing and typing the first post, it didn't..

    So the original problem is still there if using the document.write.

  4. #4
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Webbrowser control click on file:// links does not work

    Yes, the original problem is still there. Using IE or navigating to file using WebBrowser works fine but using WebBrowser and writing the html code I cannot get <a href="file://C:/Windows/">C:\Windows</a> to work. It simply does nothing.

    The only thing I can think might have something to do with it is when you navigate to a local file it enters the _DocumentComplete event and when you do document.write it does not enter the event
    but why it works for the google link and not the local folder link is beyond me
    Last edited by jmsrickland; Jul 23rd, 2015 at 12:19 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width