提交按钮无法在GeckoFX中工作

时间:2014-07-14 15:30:24

标签: c# button geckofx asp.net-webcontrol

我有这段代码:

<input type="button" onmousedown="IamTyping(0);" style="font-size:16px;" value="enter">

并在C#中尝试了这个:

GeckoInputElement enter = new GeckoInputElement(myBrowser.Document.GetElementByTagName("input").DomObject);
enter.click();

C#没有任何错误,但它不起作用!

1 个答案:

答案 0 :(得分:1)

尝试以下代码

GeckoInputElement enter = (GeckoInputElement)myBrowser.Document.GetElementsByTagName("input")
    .First(inp => ((GeckoInputElement)inp).Value == "enter");

DomEventArgs ev = browser.Document.CreateEvent("MouseEvent");
ev.DomEvent.InitEvent(new nsAString("mousedown"), true, true);
enter.GetEventTarget().DispatchEvent(ev);

ev = browser.Document.CreateEvent("MouseEvent");
ev.DomEvent.InitEvent(new nsAString("mouseup"), true, true);
enter.GetEventTarget().DispatchEvent(ev);

enter.click();