How to call a jQuery function from .NET WebBrowser control using InvokeScript()?

前端 未结 3 485
予麋鹿
予麋鹿 2020-12-19 05:41

Had a Windows Forms app using a WebBrowser control (.NET 4) to load a web page that communicated with the app. I had a call to InvokeScript() to call a Javascri

3条回答
  •  时光说笑
    2020-12-19 06:09

    For those that may not be aware, you can also use .execScript in pre-.NET versions of WB control and current/.NET versions of WB control. You can also choose the language of the script you want to execute, ie: "JScript" or "VBScript". Here is the one liner:

    WebBrowser1.Document.parentWindow.execScript "alert('hello world');", "JScript"
    

提交回复
热议问题