简体   繁体   中英

submit button not working in GeckoFX

I have this code:

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

and tried this in C#:

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

C# doesn't have any error, but it doesn't work!

try the following code

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM