Home >Web Front-end >JS Tutorial >js realizes the effect of pressing Ctrl Enter to send_javascript skills

js realizes the effect of pressing Ctrl Enter to send_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:36:071378browse

1. Listen to the onkeydown event of textarea

Copy code The code is as follows:

8db83ab39dd4eb6d2c77abf33d4c317940587128eee8df8f03d0b607fe983014

2. Send the form and then reload the opener window (see 4,)
function sbFrm() {
var Contenthf=document.getElementById("Contenthf");
var txtAr = Contenthf.getElementsByTagName("textarea")[0];
if (txtAr.innerHTML == "") {
txtAr.focus();
return false;
}
Contenthf.submit();
window.opener.afterReload();
return false;
}

3. When the ctrl key is pressed and the keycode is 13 (Enter), the function that sends the form is called.

function keySend(event) {
if (event.ctrlKey && event.keyCode == 13) {
sbFrm();
}
}

4. If it is the current page opened by window.open(), add a reload function to the page of window.open

function afterReload() {
setTimeout(function () {
window.location.reload();
}, 1000);
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn