' App.xaml.vb
Imports System.Windows.Browser
Partial Public Class App
Inherits Application
Public Sub New()
InitializeComponent()
End Sub
Private Sub Application_Startup(ByVal o As Object, ByVal e As StartupEventArgs) Handles Me.Startup
Me.RootVisual = New Page()
' HtmlDocument requires Imports System.Windows.Browser
Dim doc As HtmlDocument = HtmlPage.Document
Dim del As New EventHandler(AddressOf Me.CallGlobalJSMethod)
' Hookup the simple JScript method HTML button.
doc.GetElementById("btnCallJSMethod").AttachEvent("click", del)
End Sub
' Call a global JScript method defined on the HTML page.
Private Sub CallGlobalJSMethod(ByVal sender As Object, ByVal e As EventArgs)
Dim strMS As String = DateTime.Now.Millisecond.ToString()
Dim strTime As String = "Time came from managed code" + ControlChars.NewLine _
+ DateTime.Now.ToLongTimeString() _
+ " MS = " + strMS
HtmlPage.Window.Invoke("globalJSMethod", strTime)
End Sub
End Class