VB.NET WebBrowser禁用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
最简洁的答案是不。
稍长的答案是:不,网页浏览器控件API不允许禁用标准浏览器功能。
没有真正的......但如果你得到那个令人讨厌的错误信息,说弹出一个脚本正在运行,那么你可以把webbrowser的suppress-errors属性设置为“true”
链接地址: http://www.djcxy.com/p/62869.html上一篇: VB.NET WebBrowser disable javascript
下一篇: Detect start of a phone call to send JSON in background
