Reputation: 90465
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!')");
}
Upvotes: 1
Views: 979
Reputation: 15261
To fire events call HtmlElement.RaiseEvent To click call HtmlElement.InvokeMember and pass "click" as the method name to invoke;
Upvotes: 2
Reputation: 2263
Using InvokeScript
you can only call functions already defined on page.
Upvotes: 1
Reputation: 90465
The correct way is:
private void webBrowser1_DocumentCompleted(object sender
, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser1.Document.InvokeScript("alert", new object[] { "Hello World!" });
}
Upvotes: 2