Skip to content

SetObjectForScripting Method

Description

Gets or sets an object that can be accessed by scripting code contained within a Web page displayed in the WebBrowser control.

Syntax

Public Sub SetObjectForScripting( _
    ByVal [External](#) As Object _
)

Parameters

  • External: The object being made available to the scripting code. This is the object that contains the methods to call from HTML.

Remarks

Specifies the external object (VB Form) which contains the method(s) that will be called from an HTML file.

If you need to call a VB method from HTML, you will need to use the window.external property in HTML and then use SetObjectForScripting to set the object that contains the method(s) that will be called.

Use this property to enable communication between a Web page hosted by the WebBrowser control and the application that contains the WebBrowser control. This method lets you integrate dynamic HTML (DHTML) code with your client application code. The object specified for this property is available to Web page script as the window.external object, which is a built-in DOM object provided for host access.

Example

SetObjectForScripting Sample (Visual Basic)

This sample shows how to use SetObjectForScripting to call a VB method from HTML code.

' VB Code  

Form_Load  
    WebBrowser3.Navigate App.Path & "\Html\samplepage.html"  
    WebBrowser3.SetObjectForScripting Me  
End Sub  

Public Sub ClickFromHTML()  
    MsgBox "Messagebox from VB"  
End Sub  

HTML code in samplepage.html

<!-- This is HTML page (samplepage.html). Click me -->

See Also


Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.