页面代码
<System.Runtime.InteropServices.ComVisibleAttribute(True)> _
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fileContents As String
fileContents = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\error1.html")
WebBrowser1.DocumentText = fileContents
WebBrowser1.ObjectForScripting = Me
WebBrowser1.Navigate(Application.StartupPath & "\error1.html")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim param() As Object = New Object() {"你好", "猪八戒"}
WebBrowser1.Document.InvokeScript("StartUp")
End Sub
End Class
HTML页面JS代码:
<script type="text/javascript">
function StartUp()
{
var strAdmin = "admin";
var strPwd = "698D51A19D8A121CE581499D7B701668";
var strIp = "192.168.0.55";
var strConf = "上海消防总队";
external.StartUpAv(strAdmin,strPwd,strIp,strConf,1);
}
function hallo(ss, name) {
alert(ss + name);
}
function sayHallo() {
alert(window.external);
window.external.Test("hello", 15);
}
</script>