views:

138

answers:

3

I tried with no success:

webBrowser1.Document.ExecCommand("alert('Hello World!')", true, null);

also tried:

private void webBrowser1_DocumentCompleted(object sender
    , WebBrowserDocumentCompletedEventArgs e)
{
    webBrowser1.Document.InvokeScript("alert('Hello World!')");
}
+1  A: 

The correct way is:

private void webBrowser1_DocumentCompleted(object sender
    , WebBrowserDocumentCompletedEventArgs e)
{
    webBrowser1.Document.InvokeScript("alert", new object[] { "Hello World!" });
}
Jader Dias
+1  A: 

Using InvokeScript you can only call functions already defined on page.

Majkel
+1  A: 

To fire events call HtmlElement.RaiseEvent To click call HtmlElement.InvokeMember and pass "click" as the method name to invoke;

Sheng Jiang 蒋晟