467,087 Members | 1,216 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,087 developers. It's quick & easy.

Problem applying return false to a div via addEventListener


I'm having a problem applying return false to a div via
I'm adding this so that I can drag (click-hold-move) over an image.
(Its so that I can add zooming to the image)
Adding onmousemove="return false" onmousedown="return false" allows
this to happen but I want to add events with
addEventListener/attachEvent instead.
It works in IE6 but not firefox1.0.6
Below is code demonstrating the problem.
If you can tell me what the problem is or if I'm doing something stupid
i'd be very greatful.

Try clicking and holding then moving (dragging) over these 3 images.

<div id="myDiv0">
No events are added so this will result in a no-access sign
<img border="1" height="110" width="276" name="myImg0" id="myImg0"

<div id="myDiv1" onmousemove="return false" onmousedown="return false">
This has return false on onmousemove and onmousedown so there is no
no-access sign and you can drag over the image.<br>
<img border="1" height="110" width="276" name="myImg1" id="myImg1"

<div id="myDiv2">
This has the same return false's added except they are done via
addEventListener or attachEvent.<br>
However while you can freely drag over this image in IE6 you can't in
It seems that the return false is not being added to the event though
if I change return false to an alert these alerts are being added.<br>
<img border="1" height="110" width="276" name="myImg2" id="myImg2"


function addEvent(obj,eventType,functionReference){
obj.addEventListener(eventType,functionReference,t rue);
} else if(obj.attachEvent){

function doOnload(){

addEvent(document.getElementById('myDiv2'),'moused own',function(){return

addEvent(document.getElementById('myDiv2'),'mousem ove',function(){return
/*These two work in IE6 and Firefox so the attachement of events
appears to be working

addEvent(document.getElementById('myDiv2'),'moused own',function(){alert('down');});

addEvent(document.getElementById('myDiv2'),'mousem ove',function(){alert('move');});


Aug 5 '05 #1
  • viewed: 2236
1 Reply
Same problem here. Firefox 1.0.6-something under Gentoo Linux. I've spent hours trying to figure this one out. No luck yet. Maybe we should file a bug report. Anyway, i'm going to check the source code of firefox just in case...
Aug 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by JesusFreak | last post: by
6 posts views Thread by rich_poppleton@talk21.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.