Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想防止页面实际重新加载,然后reload()在用户按下 F5 键时运行该功能。
reload()
这可能吗,怎么做?
您可以防止刷新f5使用preventDefault jsfiddle
f5
preventDefault
document.onkeydown = function(e){ if(e.keyCode == 116){ // f5 keycode is 116 e.preventDefault(); e.returnValue = false; // for IE } }