Disabling JavaScript errors in WebBrowser control in Silverlight

六眼飞鱼酱① 提交于 2019-12-04 17:52:04

Try turning off script debugging in the internet explorers advanced settings. Ultimately the control uses MSHTML to deliver the rendering, which in turn gets many of it settings from IE.

Today I've returned to this problem in my app and I was able to resolve it somehow. Because I need to show only a pages - without much user interaction on those pages - I solve it this way.

In code I create a html with iframe with attribute security="restricted" and then I inject url to this iFrame.

My code looks like this:

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());

and then I'm using NavigateToString method of WebBrowser to load my html to it.

P.S. I've added this as an answer to accept this question.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!