使用 C# 浏览器单击 Javascript 按钮 [英] Click Javascript button with C# webbrowser
本文介绍了使用 C# 浏览器单击 Javascript 按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要让一个程序在网络浏览器中为我点击一个 javascript 按钮.这有可能吗?我想在 C# 中完成这个
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#
按钮
INPUT id=str class=text style="TEXT-ALIGN: center" maxLength=4 size=3 value=558 INPUT onclick=doIt_new(1); id=strBtn type=button value=doIt
是的,它是 Visual Studio 中的默认浏览器对象
Yes its the default webbrowser object in visual studio
推荐答案
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 });
};
这篇关于使用 C# 浏览器单击 Javascript 按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文