Forum Moderators: open

Message Too Old, No Replies

can't remove an onmousemove event from IE?

works in Firefox of course!

         

amznVibe

7:03 pm on Sep 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So I have a dynamically attached onmovemove event for a div.

Now I want to remove it dynamically.

setting this in Firefox (and everything but IE) works as expected:
obj.onmousemove='';

on IE, no dice, still fires.
Tried =null;
Tried =function(){}

Nada.
Please don't tell me I have to set a variable and if/then around it!?!

Thanks for any ideas!

Fotiman

3:53 pm on Sep 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I tried a quick test and it does, in fact, work in IE, so perhaps your 'obj' variable does not contain what you think it does. Here's a quick and dirty working example:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
<style type="text/css">
#testarea {
height: 200px;
width: 200px;
background: #c00;
}
</style>
<script type="text/javascript">
function foo() {
alert('hello');
}
function bar() {
document.getElementById('testarea').onmousemove = null;
}
</script>
<title>Untitled</title>
</head>
<body>
<div id="testarea" onmousemove="foo();"></div>
<input type="button" value="Remove onmousemove handler" onclick="bar();">
</body>
</html>

amznVibe

12:55 am on Sep 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yup it was my fault sorry. My tired eyes stupidly had me adding the events to the UL object and trying to remove them from the LI object. What's really strange is the approach somehow worked in Firefox!?!

In any case, sorry about that!