0

Hi all..i make a program use javascript to call VB.Net function..but it doesn't work...can somebody help me to check this code...

Imports System.Runtime.InteropServices

<ComVisible(True)> _
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.ObjectForScripting = True
        WebBrowser1.DocumentText = "<Script language='JavaScript'>" & vbCrLf & _
                    "function callfunction() { " & vbCrLf & _
                    "window.external.cfunction();" & vbCrLf & _
                    "}" & vbCrLf & _
                    "</script>" & vbCrLf & _
                "<a href=# onclick='callfunction'>test</a>"
    End Sub

    Public Sub cfunction()
        MsgBox("test saja", MsgBoxStyle.ApplicationModal, ProductName)
        'Return 0
    End Sub
End Class
3
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by shazi786
0

Change:
Webbrowser1.ObjectForScripting = true

to:
Webbrowser1.ObjectForScripting = Me

Greetz,
Marc

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.