Results 1 to 6 of 6

Thread: Good-old, chewed up topic about WebBrowser contol, getting it further down the road

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    186

    Good-old, chewed up topic about WebBrowser contol, getting it further down the road

    Browsing MS website, I found this page:
    http://www.microsoft.com/technet/arc....mspx?mfr=true
    which talkes about the WebBrowser control and its usage.

    Let me quote one thing from that page:
    Controlling what content is downloaded. You do this by implementing the download control ambient property, which can restrict frames, images, Java, and so on.
    This is exactly what I wanted. Below you can see few parts of my code, where I use WebBrowser to download HTML code and the contents of the page like links, etc. What I needed is to restrict WebBrowser from downloading and executing JavaScript, Flash, ActiveX, and all other useless to me items. I guess thit is what I quoted out from MS site, but how would I implement this?
    VB Code:
    1. Option Explicit
    2. Dim WithEvents myWeb As SHDocVw.InternetExplorer
    3.  
    4. Private Sub Command1_Click()
    5. Set myWeb = New SHDocVw.InternetExplorer 'create new WebBrowser control
    6. myWeb.Navigate "http://www.yahoo.com" 'go there
    7. Do While myWeb.ReadyState <> READYSTATE_COMPLETE
    8.     DoEvents '
    9. Loop
    10. Text1 = myWeb.Document.documentElement.innerHTML 'grab HTML codes
    11. 'do some other stuff here
    12. Text2 = myWeb.Document.documentElement.innerText 'grab the contents without HTML
    13. 'do some more stuff, blah, blah
    14. Set myWeb = Nothing 'trash the page
    15. 'do something else
    16. End Sub
    17.  
    18.  
    19. Private Sub myWeb_NewWindow2(ppDisp As Object, Cancel As Boolean)
    20. Set ppDisp = Nothing
    21. Cancel = True
    22. End Sub
    23.  
    24.  
    25. Private Sub myWeb_StatusTextChange(ByVal Text As String)
    26. On Error Resume Next
    27. 'this speeds things up, cause you never know what other content will load on that page
    28.     Dim ssnvar, re
    29.     ssnvar = myWeb.Document.documentElement.innerHTML
    30.     Set re = New RegExp
    31.     re.Pattern = "</body>"
    32.     re.Global = True
    33.     re.IgnoreCase = True
    34.     If re.test(ssnvar) = True Then myWeb.Stop
    35. End Sub

    To play with the above code you dont need WebBrowser control on your form, just add references to "Microsoft VBScript Regular Expressions 5.5" and "Microsoft Internet Controls". 1 Command button, and 2 Text boxes with Multiline property = True.
    Last edited by foxter; Jun 20th, 2006 at 06:24 AM.

  2. #2
    Hyperactive Member
    Join Date
    Dec 2004
    Posts
    308

    Re: Good-old, chewed up topic about WebBrowser contol, getting it further down the road

    Can you execute a button click in the page thru a webbrowser ?

    Cheers

    Chubby..

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    186

    Re: Good-old, chewed up topic about WebBrowser contol, getting it further down the road

    Quote Originally Posted by Chubby
    Can you execute a button click in the page thru a webbrowser ?

    Cheers

    Chubby..
    No with the above code. That WebBrowser will not be visible to you, because its not on the form.

  4. #4
    Hyperactive Member
    Join Date
    Dec 2004
    Posts
    308

    Re: Good-old, chewed up topic about WebBrowser contol, getting it further down the road

    Thanks,

    I don't need the form visible, just need to invoke a method of an object in a web page in a WebBrowser.. I got it to work using the following:

    Code:
        myWeb.Document.Forms("T").Hello.Click
    Thanks for the code.

    Chubby.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    186

    Re: Good-old, chewed up topic about WebBrowser contol, getting it further down the road

    Anybody knows how to implement the download control ambient property?

    Guys, please point me somewhere, any tips are greatly appreciated.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Posts
    186

    Re: Good-old, chewed up topic about WebBrowser contol, getting it further down the road

    Found an example in C++(?) http://msdn.microsoft.com/workshop/b..._and_Execution
    Any examples in VB6?

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