![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Oct 2006
Posts: 7
Rep Power: 0
![]() |
preventDefault() in Opera and Netscape
I have built a Google Suggest type dropdown suggestion box. When it is open, the user can use the mouse OR keyboard to navigate it. If they use the keyboard, the up/down arrows should navigation options, and the enter should "select" and option...but NOT submit the form. Herein lies the problem. I'm using this code in an onkeydown event attached to the input field:
if (this.asc.style.visibility != 'hidden') {
e.returnValue = false
if (typeof e.preventDefault !== 'undefined') {
e.preventDefault();
}
}The code works in IE and Firefox, but NOT in Netscape, Opera, K-Meleon, etc. Instead in those browsers it "selects" the option (this.selectOption();) AND submits the form. Also, if you are part of Experst-Exchange, feel free to get some points |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Oct 2006
Posts: 7
Rep Power: 0
![]() |
I realized that a paste-bin would be useless for future people finding this post. I'm attaching the code. In the attached version, the problem area starts on line 109
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|