MS Web Browser from HTML string

  • Thread starter Thread starter Andy Bates
  • Start date Start date
A

Andy Bates

Hi -

Could someone tell me if it is possible to set the display of the MS Web
Browser control to an HTML string?

So for instance (SetText method doesn't exist, but you get the idea):

axWebBrowser.SetText ("<html><body><b>Text to display!</b></body</html>");

I can obviously use the Navigate if it was in a file, but I just have a
string in memory. I could save it to disk, but would prefer to work solely
in memory if possible.

TIA

- Andy
 
HI Andy,

The closest thing that I can think of is to Navigate to the
"about:blank" and then set the axBrowser.Document.body.innerHTML
property to the HTML text that you want to display in the browser.

axBrowser.Document.body.innerHTML = "<b>Text to display!</b>";

Before you set the property, ensure that the navigation to "about:blank"
has completed and Document.body contains valid content..
Then there's also a way to get the text to load via the
IPersistStreamInit.Load method since the Document object
supports the IPersistStreamInit interface, but its a bit more circuitous
than
the first approach mentioned above.

Regards,
Aravind C
 
Back
Top