Results 1 to 6 of 6

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

Threaded View

  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.

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