Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-04-2012, 07:11 PM   PM User | #1
anotherJEK
Regular Coder

 
Join Date: Aug 2010
Location: Now Southern Oregon. I was born and had lived my life in Los Angeles until relocating last year (2010)
Posts: 152
Thanks: 41
Thanked 1 Time in 1 Post
anotherJEK is an unknown quantity at this point
prevent arraw key scrolling in IE?

I have an app that registers event handlers for keydown and looks for keyCode for arrow keys on keyboard. The problem is that the default action is to scroll the window if there is overflow. This is not necessary or useful in this application, and is a distraction.

How do I use returnValue to prevent this default action?
Or do I also need cancelBubble = true?

Code:
                else if(document.attachEvent)
                  {
                   document.attachEvent('onkeydown', function() { if(OBJ.gameOn) OBJ.keySwap(window.event, OBJ); });
                   window.event.returnValue = false; //// this does not seem to  do it.
                   window.event.cancelBubble = true; //// nor this
                  }
Thank you for time and attention.
anotherJEK is offline   Reply With Quote
Old 10-04-2012, 07:55 PM   PM User | #2
anotherJEK
Regular Coder

 
Join Date: Aug 2010
Location: Now Southern Oregon. I was born and had lived my life in Los Angeles until relocating last year (2010)
Posts: 152
Thanks: 41
Thanked 1 Time in 1 Post
anotherJEK is an unknown quantity at this point
I got it....

this works:
Code:
         else if(document.attachEvent)
                  {
                   document.attachEvent('onkeydown', function() { if(OBJ.gameOn) OBJ.keySwap(window.event, OBJ); window.event.cancelBubble = true; window.event.returnValue = false;} );
                  }
anotherJEK is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:29 AM.


Advertisement
Log in to turn off these ads.