HtmlDocument.InvokeScript Method

 

Executes an Active Scripting function defined in an HTML page.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

NameDescription
System_CAPS_pubmethodInvokeScript(String)

Executes an Active Scripting function defined in an HTML page.

System_CAPS_pubmethodInvokeScript(String, Object[])

Executes an Active Scripting function defined in an HTML page.

The following code example executes the contents of a script in a Web page. The code example requires that you have loaded the following Web page.

<HTML>
<SCRIPT>
function test(name, address) {
window.alert("Name is " + name + "; address is " + address);
}
</SCRIPT>

<BODY>
</BODY>
</HTML>

private void InvokeTestMethod(String name, String address)
{
    if (webBrowser1.Document != null)
    {
        Object[] objArray = new Object[2];
        objArray[0] = (Object)name;
        objArray[1] = (Object)address;
        webBrowser1.Document.InvokeScript("test", objArray);
    }
}
Return to top
Show: