Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 4
HtmlDocument Class
Collapse All/Expand All Collapse All
Members FilterMembers Filter
Frameworks FilterFrameworks Filter
This page is specific to
Microsoft Visual Studio 2010/.NET Framework 4

Other versions are also available for the following:
.NET Framework Class Library
HtmlDocument..::.InvokeScript Method

Executes an Active Scripting function defined in an HTML page.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  NameDescription
Public methodInvokeScript(String)Executes an Active Scripting function defined in an HTML page.
Public methodInvokeScript(String, array<Object>[]()[])Executes an Active Scripting function defined in an HTML page.
Top

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>
Visual Basic
Private Sub InvokeTestMethod(ByVal Name As String, ByVal Address As String)
    If (Not (WebBrowser1.Document Is Nothing)) Then
        Dim ObjArr(2) As Object
        ObjArr(0) = CObj(New String(Name))
        ObjArr(1) = CObj(New String(Address))
        WebBrowser1.Document.InvokeScript("test", ObjArr)
    End If
End Sub
C#
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);
    }
}
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker