我正在開發Silverlight OOB應用程序,並且需要在其中顯示網頁 - 我想通過WebBrowser控件完成此操作,但在頁面加載過程中,我使用JavaScript獲取大量MessageBoxes錯誤。在Silverlight中禁用WebBrowser控件中的JavaScript錯誤
有沒有隱藏這些MessageBoxes的方法?
在winform WebBrowser控件中有ScriptErrorsSuppressed
屬性可以使用,但在SL中沒有。
我將不勝感激的任何幫助。
我正在開發Silverlight OOB應用程序,並且需要在其中顯示網頁 - 我想通過WebBrowser控件完成此操作,但在頁面加載過程中,我使用JavaScript獲取大量MessageBoxes錯誤。在Silverlight中禁用WebBrowser控件中的JavaScript錯誤
有沒有隱藏這些MessageBoxes的方法?
在winform WebBrowser控件中有ScriptErrorsSuppressed
屬性可以使用,但在SL中沒有。
我將不勝感激的任何幫助。
今天我已經回到了我的應用程序中的這個問題,我能夠以某種方式解決它。因爲我只需要顯示一個頁面 - 在這些頁面上沒有太多的用戶交互 - 我就這樣解決它。
在代碼中,我創建了一個帶iframe的屬性爲security="restricted"
的html,然後我向此iFrame注入了url。
我的代碼如下所示:
var html = new StringBuilder(@"<html xmlns=""http://www.w3.org/1999/xhtml"" lang=""EN"">
<head>
<meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />
<title>{@pageTitle}</title>
<style type=""text/css"">
html {overflow: auto;}
html, body, div, iframe {margin: 0px; padding: 0px; height: 100%; border: none;}
iframe {display: block; width: 100%; border: none; overflow-y: auto; overflow-x: hidden;}
</style>
</head>
<body>
<iframe id=""tree"" name=""tree"" security=""restricted"" src=""{@PageLink}"" frameborder=""0"" marginheight=""0"" marginwidth=""0"" width=""100%"" height=""100%"" scrolling=""auto""></iframe>
</body>
</html>");
html.Replace("{@pageTitle}", Title);
html.Replace("{@PageLink}", uri.ToString());
,然後我用的WebBrowser
NavigateToString
方法,我的HTML加載它。
P.S.我已經將此添加爲接受此問題的答案。
嘗試在Internet Explorer的高級設置中關閉腳本調試。最終,該控件使用MSHTML來提供渲染,而該渲染反過來從IE獲取許多設置。
我在IE中禁用了腳本調試,但問題仍然存在。所以這是控制問題。 – 2011-02-08 15:59:58