Loading HTML into a WEB Browser Control from Variable



lcHtml = [Hello World!]
lnLoadTimeout = 3 && seconds
WITH Thisform.oWeb.OBJECT
* Wait for load completion
lnStartSeconds = SECONDS()
DO WHILE .ReadyState 4 ;
AND (SECONDS()-lnStartSeconds 4 ;
AND (SECONDS()-lnStartSeconds

$SEEALSO$ Loading XML into a WEB Browser Control from Variable


Thanks Sergey

Thanks Sergey,

This was extremely helpful. I just found myself in a situation when the WebBrowser could not finish loading a simple HTML file. (On the background I have another ActiveX component running that was probably bringing the issue). Using this aproach everything runs perfectly.
Thanks again!

Just for the records, in case this may help someone else.
My final solution was to use SYS(2333,1), to acrtvate the ActiveX dual interface support.



Sergey, the above code works perfectly. I was searching for a solution for a long time. i modifed the code to have the lcHtml be a filetostr( "c:\temp\test.html") and test.html changes as i need it to. I have a question though. When I go to load a new HTML file the code stops at the .Navigate("about:blank") . I implemented the sys( 2333,1) but that did not seem to help. I have to C-A-D/Task Manager to terminate foxpro. Any help would be appreciated.

Thanks, Josh.

Hi Josh,

Can you load HTML and than "about:blank" in IE w/o problem?

BTW, you can load HTML from a file directly

lcHtmlFileName = "c:\temp\test.html"
.Navigate2("file://" + lcHtmlFileName)

Why is it necessary to always navigate to a the "about:blank" page before loading the actual page that I want to show?

It's not necessary. I prefer to do it this way.

I'm finding that if I *do not* call the blank page, the browser control does not refresh to the new page at all.

I guess you also remove code that waits for load to complete. Anyway, The Web Browser control works much better when loading HTML from a file.

Hi Sergey.
I have problem with this Active X, send a Ole error code
and then when I run the example in this line: .Document.Open()
occurr other error. I think that the second error is a consequence of the first error.
You have any idea about that ....


Add new comment

Filtered HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.