preventDefault() on SELECT element (FF2 & FF3)

[email protected]
Newsgroups gmane.comp.mozilla.devel.dom
Organization http://groups.google.com
Message-ID <77a72860-784b-4b5f-a5ea-efae8fbfcf57@f63g2000hsf.googlegroups.com>
Hi all!
I've got a problem with preventDefault() on some FF widgets. Please
see the example below (works in Opera 9.5). The checkbox is ok but
there is no way to prevent the default action on SELECT element. I've
tried even with document.addEventListener in capture phase. And still
nothing. Any hints, workarounds?


<html>
<head>
<script type="text/javascript">
var KEY_LEFT = 0x25;
var KEY_RIGHT = 0x27;

function elem_onKey(event)
{
	switch (event.keyCode){
		case KEY_LEFT:
			//dump("left\n");
			break;
		case KEY_RIGHT:
			//dump("right\n");
			break;
		default:
			return true;//propagate
	}
	event.preventDefault();
	event.stopPropagation();
	return false;//just consume the event when it matches one of defined
keys
};

</script>
</head>
<body>
<select onkeydown="elem_onKey(event);"
		onkeyup="elem_onKey(event);"
		onkeypress="elem_onKey(event);">
	<option> a </option>
	<option> b </option>
	<option> c </option>
	<option> d </option>
</select>
<br>
<form>
<input type="checkbox" onclick="event.preventDefault();"
onmouseover="event.preventDefault();"
onmousedown="event.preventDefault();"/>
<label for="checkbox">Checkbox</label>
</form>
</body>
</html>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.