我想做的是从 javascript 调用一个 vb.net 函数,
这是我的 html 代码。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled
Page
</title>
<script
src="jquery.js"></script>
<script
type="text/javascript">
$(function(){
$("button").click(showVbHelloWorld)
function
showVbHelloWorld()
{
window.external.showVbHelloWorld();
}
})
</script>
</head>
<body>
<button>A</button>
</body>
</html>
这是我的 vb.net 代码
Imports System
Imports System.Windows.Forms
Imports System.Security.Permissions
<PermissionSet(SecurityAction.Demand, Name:="FullTrust")>
<System.Runtime.InteropServices.ComVisibleAttribute(True)>
<Microsoft.VisualBasic.ComClass()>
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Me.WebBrowser1.ObjectForScripting = Me
End Sub
Public Sub showVbHelloWorld()
MsgBox("Hello")
End Sub
End Class
仍然在按钮上单击我得到错误未捕获的类型错误
:对象#没有方法'showVbHelloWorld'
对不起我的代码格式不均匀......我是stackoverflow的新手......