Forms.WebBrowser strange behavour
I have a Webbrowser control that I am using to generate thumbnails of web pages. Below is my code:
webBrowser.AllowNavigation = true;
webBrowser.Navigate(@"about:blank");
webBrowser.DocumentText = url;
if (webBrowser.Document != null)
webBrowser.Document.Write(url);
Where url is a string containing the html.
Using the above code results in webBrowser.DocumentText
sometimes being populated with my htm开发者_开发问答l and othertimes not.
However I have found that line 3 and 5 are basically doing the same thing and webBrowser.Document.Write(url);
is a much better way of writing the html to the browser, so I removed line 3 and it works everytime.
So my question is why by having line 3 does it cause it to fail occasionally, since line 5 is in effect making line 3 redundant anyway?
Docs for DocumentText
say that
If you set the value of this property and then immediately retrieve it again, the value retrieved may be different than the value set if the WebBrowser control has not had time to load the new content.
精彩评论