问题
I have a flash embed code in my webpage. When playing the game, page is scrolling with Up and Down keys. How can i prevent this? Firefox is ok, but it's only scrolling in IE.
回答1:
A jQuery way of handling this:
$(document).bind('keydown keypress', function(e) {
if(e.keyCode > 36 && e.keyCode < 41) e.preventDefault();
});
The page scrolls when the arrow keys (key 37-40) are hit (keydown) and when they're kept down (keypress). So, if this happens we prevent the default event by e.preventDefault();
来源:https://stackoverflow.com/questions/5446069/disable-scrolling-with-arrow-keys-in-flash