使用C#webbrowser单击Javascript按钮
我需要让程序在webbrowser中为我单击javascript按钮。这有可能吗?我想用C语言完成这个任务# 按钮使用C#webbrowser单击Javascript按钮,c#,javascript,html,C#,Javascript,Html,我需要让程序在webbrowser中为我单击javascript按钮。这有可能吗?我想用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 是的,如果您使用的是WinForm webbrowser控件,则它是visual studio
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
是的,如果您使用的是WinForm webbrowser控件,则它是visual studio中的默认webbrowser对象。它允许在WebBroswer控件中托管的文档内部执行JavaScript。
string html=
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 });
};
@"
函数doIt_new(x){
警报(x);
}
";
webBrowser1.DocumentText=html;
webBrowser1.DocumentCompleted+=(s,e)=>
{
webBrowser1.Document.InvokeScript(“doIt_new”,新对象[]{1});
};
web浏览器是默认的IE浏览器吗?请确认-您正在WinForm上使用WebBrowser控件?