1

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!')");
}

3 Answers 3

2

The correct way is:

private void webBrowser1_DocumentCompleted(object sender
    , WebBrowserDocumentCompletedEventArgs e)
{
    webBrowser1.Document.InvokeScript("alert", new object[] { "Hello World!" });
}
Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.