[英]C# Webbrowser Onclick Javascript event handling
I got this code from HTML: 我从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 ) 现在,我需要一个C#代码来激活/单击网页(已加载到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 :)
只是问:)
InvokeScript
executes a function by name, rather than evaluates the code. InvokeScript
按名称执行函数,而不是对代码求值。 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 在C#代码中,按名称调用函数
webBrowser1.Document.InvokeScript("foo");
There's more information on the documentation which covers how to pass parameters and receive results. 有关文档的更多信息,其中包括如何传递参数和接收结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.