How to Press the button with JavaScript.
function fnLoginPressEnter(obj) {
if (this.event.keyCode == 13) {
Ncucu.Login(document.forms[0]);
}
}
that's so wrong
webBrowser1.Document.InvokeScript("fnLoginPressEnter");
使用onkeydown =“ if(event.keyCode == 13)document.getElementById('[YOUR_BUTTON_ID]')。click()”
If you using jQuery, you can do this:
$('#button_id').click();
or you can create manually an click event:
var el=document.getElementById('button_id');
if (!el.dispatchEvent) {
el.fireEvent('onclick');
} else {
var e = document.createEvent('MouseEvents');
e.initMouseEvent('click', false, true, top, 1, 0, 0, 0, 0, false, false, false, false, 0,
null);
el.dispatchEvent(e);
}
Use this one with your requirement like onkeyup
eg:
onkeyup="javascript:KeyUp(event);"
function KeyUp(event)
var v = event.keyCode ? event.keyCode : event.charCode;
if (v == "13") {
document.getElementById('btnSubmit').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.