I have a WPF application that uses the WPF WebBrowser control to display interesting web pages to our developers on a flatscreen display (like a news feed).

The trouble is that I occasionally get a HTML script error that pops up a nasty IE error message asking if I would like to "stop running scripts on this page". Is there a way to suppress this error checking?

8 Answers
8

The problem here is that the WPF WebBrowser did not implement this property as in the 2.0 control.

Your best bet is to use a WindowsFormsHost in your WPF application and use the 2.0's WebBrowser property: SuppressScriptErrors. Even then, you will need the application to be full trust in order to do this.

Not what one would call ideal, but it's pretty much the only option currently.

+1 Thanks for this - I really didn't fancy the overhead of using a 'WindowsFormsHost' to get this functionality and your code seems to do the job honourably.
–
SheridanSep 5 '11 at 14:57

How do you add this to webbrowser object ?
–
MonsterMMORPGMar 16 '12 at 2:25

4

var wb = new WebBrowser(); wb.Navigated += (a,b)=>{ HideScriptErrors(wb, true); }; Only need to run this once, but you get the idea. You cant set the property until the Navigated event has been fired.
–
Wolf5Apr 12 '12 at 13:14

Actually I have it working with 8.1 and 4.5 in production program, but the code is probably changed from that example. If you are interested I can try to verify new code and do an updated post.
–
AlkampferAug 23 '14 at 16:03