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
Release: 2016-05-16 16:36:07
Original
1376 people have browsed it

1. Listen to the onkeydown event of textarea

Copy code The code is as follows:



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;
}
Copy after login

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();
}
}
Copy after login

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);
}
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template