[點(diǎn)晴永久免費(fèi)OA]C#.net之WinForm開發(fā)中屏蔽WebBrowser腳本錯誤提示的方法
當(dāng)前位置:點(diǎn)晴教程→點(diǎn)晴OA辦公管理信息系統(tǒng)
→『 經(jīng)驗分享&問題答疑 』
通常在C#的實際開發(fā)過程中,會發(fā)現(xiàn)設(shè)置其屬性scriptErrorsSuppressed為true還是無法達(dá)到屏蔽腳本錯誤的效果,但是可以通過下面兩種方式實現(xiàn)這一效果。 1.在DocumentCompleted事件中訂閱Error處理,代碼如下所示: private void wbGoogleMap_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { wbGoogleMap.Document.Window.Error += new HtmlElementErrorEventHandler(Window_Error); } void Window_Error(object sender, HtmlElementErrorEventArgs e) { e.Handled = true; } 2.在腳本中window.onerror中處理,代碼如下所示: window.onerror = function(error, url, line) { // log(error + "url:" + url + "lineNo:" + line); return true; } 通過上述兩種方法能夠很好的屏蔽WebBrowser腳本錯誤提示。 該文章在 2022/12/15 15:40:45 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |