Costa Mirkin
Costa Mirkin

Reputation: 977

Open generated Web Page with WebBrowser object in VB

I'd like to know if it possible to show HTML page created in VB using WebBrowser object without using files on disk. That is, create HTML file in memory and show it within WebBrowser object. Thanks!

Upvotes: 7

Views: 5486

Answers (3)

Sheng Jiang 蒋晟
Sheng Jiang 蒋晟

Reputation: 15271

First wait for the DocumentComplete event (navigate to about:blank if you start from scratch), then use the document's IPersistMoniker (recommended if you want to provide a base url) or IPersistStreamInit interface to load HTML content.

You can find an example (the LoadHtmlIntoBrowser method) in the csexwb project.

Upvotes: 2

Adriano Silva
Adriano Silva

Reputation: 2576

Using Visual Basic in .Net Framework...

webBrowser1.DocumentText = "<html><body><a href='http://www.mywebsite.com'>My Web Site</a></body></html>"

In old Visual Basic 6, try...

WebBrowser1.Document.Open
WebBrowser1.Document.Write "<html><body><a href='http://www.mywebsite.com'>My Web Site</a></body></html>"
WebBrowser1.Document.Close

Upvotes: 4

Costa Mirkin
Costa Mirkin

Reputation: 977

Well, I've found the solution. It's not so complicated. The solution is to run from the VB: *

  • WebBrowserObject.Navigate "about:HTML TEXT"
  • It works, I've checked it.

Upvotes: 0

Related Questions