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.
我有一个 javascript window.open 弹出窗口,我想防止弹出窗口在用户按下 ESC 键时自行关闭。我不知道如何挂钩 keydown 事件(以及在什么对象上?),以便我可以抓住 ESC 键。
请帮帮我!
var myWindow = window.open(); myWindow.onkeydown = function(e){ if(e.keyCode === 27){ e.preventDefault(); } };