Disabling JavaScript errors in WebBrowser control in Silverlight

4.8k Views Asked by At

I'm developing Silverlight OOB application and I need to show web pages in it - I would like to do it through out WebBrowser control, but during page load I get lots of MessageBoxes with JavaScript errors.

Is there a way of hiding those MessageBoxes?

In winform WebBrowser control there is ScriptErrorsSuppressed property that can be used, but in SL there isn't.

I would be appreciated for any help.

2

There are 2 best solutions below

0
On BEST ANSWER

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.

2
On

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.