gpt4 book ai didi

c# - WebBrowser 控件 - 使用 JavaScript 按钮调用脚本问题

转载 作者:行者123 更新时间:2023-11-29 10:50:32 24 4
gpt4 key购买 nike

我正在尝试登录网站。我能够使用所有连接信息正确填写表格,但无法让页面登录。按钮是没有名字和id的链接,所以不能直接点击。我一直在研究 invokeScript() 的东西,但这似乎也不起作用。这是按钮代码:

<div style="float:left; width:50px; margin: 0px auto 0px auto; text-align:center;">
<div id="loginBtn">
<a href="#" style="text-decoration:none; font-weight:bold; font-size: 10px; color:#FFFFFF;" onClick="javascript: LoginSubmit(event, true);" tabindex="3">
Log In
</a>
</div>
</div>

我怎样才能点击这样的链接?

我试过这样的东西:

webBrowserControl.InvokeScript("LoginSubmit", "true" );

webBrowserControl.InvokeScript("LoginSubmit(event, true)");

webBrowserControl.InvokeScript("LoginSubmit", new object[] { new string[] { "event", "true" } });

最佳答案

您可能缺少文档,如下所示:

webBrowserControl.Document.InvokeScript(名称, 参数)

如果没有,请尝试使用 this wrapper method 调用脚本, 摘录:

private object MyInvokeScript(string name, params object[] args) 
{
return webBrowserControl.Document.InvokeScript(name, args);
}



int x = 50;
int y = 100;
MyInvokeScript("LoginSubmit",x, y);

关于c# - WebBrowser 控件 - 使用 JavaScript 按钮调用脚本问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11001014/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com