
Rendering Modified HTML in WebBrowser Control
Quote:
>I have a VB app that has the browser control in it to navigate html pages.
>There are certain pages that have a banner on them that I would not like
>displayed when viewing with the VB app (I want the banner when view in
>straight IE)
>Is there anyway to parse the HTML - take out the banner - then tell the
>WEbbrowser control to render the modified HTML?
>I thought of using the InetCtl to download the HTML - then parse it and save
>to a local file then have webbrowser display that - seems kinda bulky
>though.
Look at the M/S HTML Library (comes with IE5). It allows you to parse
and change the HTML in a web browser control. There's almost no info
available on it, and the following code is about all I've seen. It comes
from an MSDN article that was removed !! If you have access to MSDN CDs,
have a look for a Web Workshop article called "Scraping Web Pages". It
gives some info. It was also printed in the paper edition of MSDN News
in the May/June 2000 edition.
' the first bit of code adds all links to a list box
Dim doc As IHTMLDocument2
Set doc = wb.document ' get the HTML from the web browser
list.Clear
Dim anchors As IHTMLElementCollection
Set anchors = doc.All.tags("A")
Dim i As Integer
For i = 0 To anchors.length - 1
list.AddItem anchors.Item(i, i)
Next
' following code from MSDN article May/June 2000
Dim Tables As IHTMLElementCollection
Set Tables = doc.All.tags("TABLE")
Dim Quote As IHTMLElement
' get the 14th item in the table
Set Quote = Tables.Item(14, 14).All.tags("TD").Item(2, 2)
MsgBox Quote.innerText
--
Alan Silver
Please remove the "{*filter*}ferret" if replying by e-mail