1

I got this code from HTML:

<div id="login-buttons">
    <div id="js_login_button">
        <a href="#" onclick="$('#login_form').submit()" class="login_button">
        <span class="button_left"></span>
        <span class="button_middle">Login</span>
        <span class="button_right"></span>
        </a>
    </div>          
</div>

Now I need a C# code to activate / perform a click into the webpage (which is loaded into a webBrowser)

//webBrowser1.Document.InvokeScript("$('#login_form').submit()");

This doesn't work for me, I tried and searched a lot but I can't find anything. I CANNOT add a function because It's from a website.

Please help me :)

Note: If you need more information from which website I want to make an auto login system. Just ask :)

meshy
  • 8,470
  • 9
  • 51
  • 73
  • 1
    http://stackoverflow.com/questions/12252378/capturing-a-form-submit-with-jquery-and-submit – Zaki Jul 12 '13 at 09:21

1 Answers1

0

InvokeScript executes a function by name, rather than evaluates the code. Define a function by name that does what you want.

<script>
   function foo () {
      $('#login_form').submit()
   };
</script>

In the C# code, call the function by name

webBrowser1.Document.InvokeScript("foo");

There's more information on the documentation which covers how to pass parameters and receive results.

Jeff Foster
  • 43,770
  • 11
  • 86
  • 103