How do I suppress script errors when using the WPF WebBrowser control?

前端 未结 8 1810
余生分开走
余生分开走 2020-12-02 09:34

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 tro

8条回答
  •  盖世英雄少女心
    2020-12-02 10:22

    I wanted to add this as a comment to @Alkampfer answer, but I don't have enough reputation. This works for me (Windows 8.1, NET 4.5):

     window.Browser.LoadCompleted.Add(fun _ -> 
        window.Browser.Source <- new System.Uri("javascript:window.onerror=function(msg,url,line){return true;};void(0);"))
    

    This code sample is written in F#, but it's pretty clear what it does.

提交回复
热议问题