편집

다음을 통해 공유


HtmlElement.InvokeMember Method

Definition

Executes a method unique to the current element.

Overloads

InvokeMember(String, Object[])

Executes a function defined in the current HTML page by a scripting language.

InvokeMember(String)

Executes an unexposed method on the underlying DOM element of this element.

InvokeMember(String, Object[])

Executes a function defined in the current HTML page by a scripting language.

public:
 System::Object ^ InvokeMember(System::String ^ methodName, ... cli::array <System::Object ^> ^ parameter);
public object InvokeMember (string methodName, params object[] parameter);
public object? InvokeMember (string methodName, params object[]? parameter);
member this.InvokeMember : string * obj[] -> obj
Public Function InvokeMember (methodName As String, ParamArray parameter As Object()) As Object

Parameters

methodName
String

The name of the property or method to invoke.

parameter
Object[]

A list of parameters to pass.

Returns

The element returned by the function, represented as an Object. If this Object is another HTML element, and you have a reference to the unmanaged MSHTML library added to your project, you can cast it to its appropriate unmanaged interface.

Examples

The following code example gets a TABLE called dataTable and uses the unexposed moveRow method to move a row from the end of the table to the beginning.

private void ShiftRows(String tableName)
{
    if (webBrowser1.Document != null)
    {
        HtmlDocument doc = webBrowser1.Document;
        HtmlElementCollection elems = doc.All.GetElementsByName(tableName);
        if (elems != null && elems.Count > 0)
        {
            HtmlElement elem = elems[0];

            // Prepare the arguments.
            Object[] args = new Object[2];
            args[0] = (Object)"-1";
            args[1] = (Object)"0";

            elem.InvokeMember("moveRow", args);
        }
    }
}
Private Sub ShiftRows(ByVal TableName As String)
    If (WebBrowser1.Document IsNot Nothing) Then
        With WebBrowser1.Document
            Dim Elems As HtmlElementCollection = .All.GetElementsByName(TableName)
            If (Not Elems Is Nothing And Elems.Count > 0) Then
                Dim Elem As HtmlElement = Elems(0)

                ' Prepare the arguments.
                Dim Args(2) As Object
                Args(0) = CObj("-1")
                Args(1) = CObj("0")

                Elem.InvokeMember("moveRow", Args)
            End If
        End With
    End If
End Sub

Remarks

This method can be used to call methods from the Document Object Model (DOM) that do not have equivalents in managed code. All arguments supplied to InvokeMember will be converted to Win32 VARIANT data types before they are passed to the named scripting function.

Applies to

InvokeMember(String)

Executes an unexposed method on the underlying DOM element of this element.

public:
 System::Object ^ InvokeMember(System::String ^ methodName);
public object InvokeMember (string methodName);
public object? InvokeMember (string methodName);
member this.InvokeMember : string -> obj
Public Function InvokeMember (methodName As String) As Object

Parameters

methodName
String

The name of the property or method to invoke.

Returns

The element returned by this method, represented as an Object. If this Object is another HTML element, and you have a reference to the unmanaged MSHTML library added to your project, you can cast it to its appropriate unmanaged interface.

Remarks

This method can be used to call methods from the Document Object Model (DOM) that do not have equivalents in managed code. Use this version of InvokeMember to execute unexposed methods that take no arguments. For an example, see InvokeMember.

Applies to