Skip to content Skip to sidebar Skip to footer

Click Javascript Button With C# Webbrowser

I need to make a program click a javascript button for me in the webbrowser. Is this possible in any way? I want to accomplish this in C# the button INPUT id=str class=text style='

Solution 1:

If you're using WinForm WebBrowser control - take a look at webBrowser.Document.InvokeScript method. It allows to execute JavaScript inside of a document, hosted in WebBroswer control.


Solution 2:

string html =
  @"<html>
    <script>
        function doIt_new(x){
            alert(x);
        }
    </script>
    </html>";

webBrowser1.DocumentText = html;
webBrowser1.DocumentCompleted += (s, e) =>
{
    webBrowser1.Document.InvokeScript("doIt_new", new object[] { 1 });
};

Post a Comment for "Click Javascript Button With C# Webbrowser"