Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force WebBrowser control to interpret HTML in memory

Status
Not open for further replies.

Glasgow

IS-IT--Management
Jul 30, 2001
1,669
GB
Is it possible to force a WebBrowser control to interpret some HTML without using the Navigate method to open a file on disk or a page on the web?

I have some HTML extracted from a database and I just want to display it, preferably without having to write it to a file first.

Could I manipulate the Document object somehow - e.g.
Code:
WebBrowser1.Document.HTML = MyHTML
where I have invented the .HTML property!
 
Put a WebBrowser control on your form and run the following code.
___
[tt]
Private Sub Form_Load()
WebBrowser1.Navigate "about:blank"
End Sub

Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
If URL = "about:blank" Then
WebBrowser1.Document.body.innerHTML = "<h1>Hello World!</h1>"
End If
End Sub[/tt]
 
Yes! That's the kind of thing, thank you very much. I knew there was a property somewhere and I realise now that I've used InnerHTML before but only in a 'read only' context. I always have problems finding what I want in the Document object model documentation!

However....

I have been using a workaround (writing to file then navigate to that file) which works fine but when I now use the InnerHTML property, it does not render correctly. I think that this may be because my HTML constitutes an entire page and the InnerHTML property should only be used when the HTML is being placed between the <body> & </body> tags. Is there a way I can manipulate the HTML object and/or OuterHTML property? Again I am struggling with the documentation.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top