If instead of navigating to a webpage in a WebBrowser, you want to set the HTML property directly, what's the proper way to do it?
Is it like this?
myWebBrowser.Navigate("about:blank");
myWebBrowser.Document.Write("<html><body>Test</body></html>");
Using this (instead of the about:blank document.write combo):
myWebBrowser.DocumentText = sourceCode;
seems to solve various issues such as running the following JavaScript when IE7 is installed on the system:
window.location = "#test";
If IE 7 is installed, this will cause an Error: Invalid argument message to appear.
您还可以使用WebBrowser.DocumentStream属性来编写所需的数据。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.