Community discussion forum

[18] WebBrowser Control

Tags:
  • 10 years ago

    This thread is for discussions of WebBrowser Control.

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 6 years ago

    The combobox doesn't display the current web page, only the last one entered. i.e. type in a site, then click back to the home site, the combobox will still display the site you typed in.

  • 6 years ago

    you need to enter a code like this

    Code:

    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As _
    Object, URL As Variant)
       Me.Caption = WebBrowser1.LocationName &  "What ever you called ur browser" (optional)
       cbocombobox.Text = WebBrowser1.LocationURL
       
    End Sub

  • 5 years ago

    where can i find the .dll file?

  • 5 years ago

    Does anyone have any ideas why my browser window would come up blank.  No matter where I tell it to navigate to it remains blank.  I've tried the code on two computers with the same results.


    I'm using the code in Excel 2000's VBA.


    Thanks

  • 5 years ago

    I am submitting a form on a page, but it won't get the 'action' page unless I step through the code line by line in VB (use the f8 key to step).  It seems like the vb runs so fast that it is just one step ahead of the browser control and the control never catches up.  I end up with the form still in the control window and not the action page.


    The page has a form called simpleform and I call the submit method, like so


    wb.Document.simpleform.submit


    I think do a loop to allow the browser time to get the resultant page, like so:


    Do While wb.Busy
    Loop


    any ideas?


  • 5 years ago

    yes. you need to do soemthing like


    Do While wb.ReadyState<>DocumentComplete
      DoEvents
    Loop


    and possibly add a timeout. (you need to change the DocumentComplete bit - i can't remember the exact names of the constants)

  • 5 years ago

    Any ideas why a page might get hung/stuck in "READYSTATE_INTERACTIVE"?


    I think I might understand what is happening.  I am submitting and checking the readystate, like so:


    Do Until Web1.ReadyState >= READYSTATE_COMPLETE
         DoEvents
    Loop


    However the 'readystate' never gets to READYSTATECOMPLETE (=4) it only gets to READYSTATEINTERACTIVE (=3).  According to Microsoft that means that the page won't accept user input, I.E., until it achieves READYSTATE_COMPLETE status.  In practice that means I can't do things like fill out a form on the page or click a link on the page (and that is what I want to do).  


    The page I am loading is MY OWN PAGE and it gets hung at READYSTATE_INTERACTIVE (=3).  I have no idea why the page gets hung there except for maybe it is poorly formed html (it is really large and I should probably trim it down).  As usual, MS doesn't give any explanation of for why a page might get hung in a particular state so I am just guessing.  


    I am going to trim the page down and see if that works.

  • 5 years ago

    well, I think I have a workaround.  It appears that the document will never acheive the complete readystate.  I tried to identify the problem and I isolated it down to some javascript code in the page that doesn't run correctly (fyi, I think the originator of the page put the javascript in purposely to prevent people from scraping his site as I am doing).


    Anyway, if it doesn't go to completion you can still get the html of the page by checking the web1.document.body.innerHTML property.  I then parse that for the (dynamic) link that I need and navigate directly to the link.  Here is the code for parsing anchor tags and hrefs, you need to have a reference for microsoft vbscript in your project to use regular expressions:


    Public Function sParseHref(sMatch As String) As String
       'returns a url that matches your sMatch string
       Dim sPat As String, oHrefMatch As Variant
       Dim objSrc As Variant, sHref As String
       Dim rReg As RegExp
       Dim oAnchorTag As Variant
       Dim sHrefPat As String, objMatch As Variant
       Dim sHTML As String
       sParseHref = ""
       Set rReg = New RegExp
       sPat = "<A\s(.?)>"
       rReg.Pattern = sPat
       rReg.Global = True
       rReg.IgnoreCase = True
       sHTML = Web1.Document.body.innerHTML
       'Execute the regular expression on the raw HTML
       Set oAnchorTag = rReg.Execute(sHTML)
       'Step through our matches
       For Each objMatch In oAnchorTag
    '       response.write server.htmlencode(objMatch.Value) & "<p>"
           sHrefPat = "href=""?(.
    ?)[\s"">]"
           rReg.Pattern = sHrefPat
           Set objSrc = rReg.Execute(objMatch.Value)
           For Each oHrefMatch In objSrc
               sHref = Trim(Replace(Replace(Replace(oHrefMatch.Value, """", ""), "href=", "", 1, 1, 1), ">", ""))
               If InStr(1, sHref, sMatch, 1) > 0 Then
                   sParseHref = sHref
                   GoTo gotit
               End If
           Next
       Next
    gotit:
       Set objSrc = Nothing
       Set rReg = Nothing
       Set objMatch = Nothing
       Set oAnchorTag = Nothing
    End Function

  • 5 years ago

    is it possible to disable the drag and drop feature of the web browser control?


    i.e stop the user from clicking on a file on the desktop or in a folder and dragging it into the web browser window.


    Thanks.

  • 4 years ago

    Ey, I made It and the mnuOpen option wont work, and I wanted to know if there was a way to get a progress bar at the bottom like on netscape and IE???

  • 3 years ago

    I want Free downloadble books for visual basic 6.0.If you have any Free
    Download books  address for visual basic reply to me.

  • 3 years ago

    nothing..........

  • 3 years ago

    I have a problem with usb ports in windows xp home.
    I have my modem connected and working
    printer connected and working
    mouse keyboard connected and working
    my camera will work
    I have been trying to connect a storage device 80mb usb2 pcmcia type 2 card.the system recognises the device but tells me it needs formatting but if i tell kt ok it stops.the usb drive works on another machine
    i have tried removing all usb ports in device manager and reinstalling. still no joy
    I have tried other storage devices and i get the same message with these
    the storage device works on other machines.
    Help
    Is it that i am using too much power past the 500ma and need a powered hub
    can any one throw some light please
    Frustrated 12 hours spent now i really dont want to have to do a reinstall of xp if i can help it

  • 3 years ago

    Another quirk I have noticed with WebBrowser is that the Graphics methods dont not work on it.

  • 3 years ago

    Hi,
    I have created a web browser for it to load tankmania.com but what i need to know is how do i get a button to interact with the web browser eg: I click the button and it send a keyboard event to the web browser eg '' + ''. I have tried loads of things and nothing has been successfull, please help?

  • 3 years ago

    hey try to be more discrete i know hwo u are

  • 2 years ago

    hi

    it is a great browser :D

    but where is th GO button?!!?!

  • 8 months ago

    Hi, As i know so far there is no go button, to create a button that takes you to a link you have to use a textbox (txtLink) and a button(btnlink) controls.

    In the button on click event handler, enter the navigate method of the webrowser example;

    webbroswer.navigate(txtlink.text)

    I know that is a little bit late but it may be usefull to those visiting.

     

Post a reply

Enter your message below

Sign in or Join us (it's free).