最近在Debug 會用到WebBrowser Control 其中有些問題很惱人,想說紀錄一下..
1. 如何關閉 指令碼偵錯視窗
解決方法
webBrowser1.ScriptErrorsSuppressed = true;MSDN 位置 : http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.scripterrorssuppressed.aspx
2.如何針對讓WebBrowser 來載入HTML Code 而非一個網址
作法有兩種第一種是存成一個local html 然後 去load 該檔案
還有一種就是使用WebBrowser.Document.Write 網路上作法很多,雖然都成功
但是如果在load 另外一段html code 都會發生無法再載入的問題.
後來找到一段寫法問題才解決
webBrowser1.Navigate("about:blank");if (webBrowser1.Document != null)
{ webBrowser1.Document.Write(string.Empty);}
webBrowser1.DocumentText = HTMLCODE ;
這方法應該是目前測試到現在最好的做法…
筆記一下..
--
The bug existed in all possible states. Until I ran the code.
如果這篇文章有幫助到您幫我分享一下,讓我有寫下去的動力...