简体   繁体   English

VB.NET WebBrowser控件OnClick事件未触发

[英]VB.NET WebBrowser Control OnClick Event Not Triggering

I'm using Vb.Net to trigger event listeners in a web-browser control, however it only seems to work on some site and not on others... 我正在使用Vb.Net来触发Web浏览器控件中的事件侦听器,但是它似乎仅在某些站点上起作用,而在其他站点上却不起作用...

WebBrowser1.Document.GetElementById("button name").InvokeMember("click")
WebBrowser1.Document.GetElementById("button name").InvokeMember("Onclick")

It works on sites like adf.ly, gmail, google, but not on others. 它适用于adf.ly,gmail,google等网站,但不适用于其他网站。 for example, On the airserver log in website ( http://www.airserver.com/Download ) it only works for some buttons. 例如,在airserver登录网站( http://www.airserver.com/Download )上,它仅适用于某些按钮。 The "download for free" and "buy now" buttons all work. “免费下载”和“立即购买”按钮都可以使用。

But, the popup (comes up when you press download for free) has a "register for trial" button. 但是,弹出窗口(当您按下免费下载时出现)有一个“注册试用”按钮。 I have tried to use these codes, they do not work. 我试图使用这些代码,但它们不起作用。 (Yes, I have put in my name and email into the required fields) (是的,我已经在必填字段中输入了我的姓名和电子邮件地址)

WebBrowser1.Document.GetElementById("registrButton").InvokeMember("click")
WebBrowser1.Document.GetElementById("registrButton").InvokeMember("Onclick")

I have also looked at the chrome event break-point, it tells me that it a "click" event was triggered. 我还查看了chrome事件断点,它告诉我它触发了“ click”事件。

This is the html code for the button if you are not bothered to go to airserver 如果您不麻烦去airserver,这是按钮的html代码

<a id="registrButton" class="button register" href="#" onclick="$('#promoRequest').submit();return false;">Register for Trial</a>

It's because it's a pop up (probably ajax and the code is not viewable in the webbrowser). 这是因为它是一个弹出窗口(可能是ajax,并且在Web浏览器中看不到代码)。

But the solution is here, use this link would 100% work: http://www.airserver.com/register/PC 但是解决方案在这里,使用此链接将100%起作用: http : //www.airserver.com/register/PC

then redirect back to your download page, and do whatever you were doing. 然后重定向回您的下载页面,然后执行您的所有操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM