Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用C#webbrowser单击Javascript按钮_C#_Javascript_Html - Fatal编程技术网

使用C#webbrowser单击Javascript按钮

使用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

我需要让程序在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中的默认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控件?