VB.NET WebBrowser disable javascript

有没有办法在vb.net中禁用javascript webbrowser?


为我工作:

Private Function TrimScript(ByVal htmlDocText As String) As String


    While htmlDocText.ToLower().IndexOf("<script type=""text/javascript"">") > -1
        Dim s_index As Integer = htmlDocText.ToLower().IndexOf("<script type=""text/javascript"">")
        Dim e_index As Integer = htmlDocText.ToLower().IndexOf("</script>")
        htmlDocText = htmlDocText.Remove(s_index, e_index - s_index)
    End While
    Return htmlDocText

End Function

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim webClient As New System.Net.WebClient
    Dim result As String = webClient.DownloadString(yourUrl)
    Dim wb As New WebBrowser
    wb.Navigate("")
    Do While wb.ReadyState <> WebBrowserReadyState.Complete
        Application.DoEvents()
    Loop
    Dim script As String = TrimScript(result)
    wb.DocumentText = script

End Sub

The short answer is: No.

The slightly longer answer is: No, the web-browser control API does not allow disabling standard browser functionality.


没有真正的......但如果你得到那个令人讨厌的错误信息,说弹出一个脚本正在运行,那么你可以把webbrowser的suppress-errors属性设置为“true”

链接地址: http://www.djcxy.com/p/62870.html

上一篇: C#停止加载图像,flash,脚本等webbrowser控件

下一篇: VB.NET WebBrowser禁用JavaScript