Event cancelinf in Firefox

M

Marcin Nowak

Hi!

I want to cancel up and down arrows in list (select) element.
Here is the code:

<script>

function Arrows (event)
{
code = event.keyCode;
if (code == 38)
alert('Up');

if (code == 40)
alert('Down');


if (event.stopPropagation)
event.stopPropagation();
else
event.cancelBubble = true;

if (event.preventDefault)
event.preventDefault();
else
event.returnValue = false;
return false;
};


</script>

<form id="theform">
<select id="answ" name="answ" style="width:300px"
multiple size="5" onkeydown="return Arrows(event);">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
<option value="4">four</option>
<option value="5">five</option>
</select>
</form>


It works in IE but doesn't in Firefox. Any ideas how to fix it?

Marcin
--
Marcin Nowak
www.wyprawa.net [email protected]_m.ik.n_et_
Ochrona adresu: usun kropki z wyjatkiem ostatniej, podkreslenia
oprócz pierwszego. Address protection: remove dots except for
the last one, underscores excluding the first one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top