1.javascript版 document.onkeyup = function (e) { if (window.event)//如果window.event对象存在,就以此事件对象为准 e = window.event; var code = e.charCode || e.keyCode; if (code == 13) { //此处编写用户敲回车后的代码 } } 2.jquery版 document.onkeyup = function (e) { if (window.event)/
function bindDOMEvents() { $(document).keydown(function (e) { var key = e.which || e.keyCode; if (key == 116) { isPopUpComfirm = false; } }); // Attach the event click for all links in the page $("a").bind("click", function () { isPopU
document.addEventListener('visibilitychange', function() { console.log(isHidden() + "-" + new Date().toLocaleTimeString()) }); function getHiddenProp() { var prefixes = ['webkit', 'moz', 'ms', 'o']; // if 'hidden' is natively supported just retu
闭包js函数的嵌套定义,定义在内部的函数 就称之为闭包为什么使用闭包: 1.一个函数要使用另一个函数的局部变量 2.闭包会持久化包裹自身的函数的局部变量 3.解决循环绑定 function outer() { var num =10; function inner() { //1.在inner函数中,使用了outer的局部变量num return num; } return inner; } var innerFn = outer(); //2.借助闭包,将局部变量num的声明周期提升了 var