473,405 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Problem applying return false to a div via addEventListener

Hi

I'm having a problem applying return false to a div via
addEventListener.
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
appearing.<br>
<img border="1" height="110" width="276" name="myImg0" id="myImg0"
src="http://www.google.co.uk/intl/en_uk/images/logo.gif">
</div>

<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"
src="http://www.google.co.uk/intl/en_uk/images/logo.gif">
</div>

<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
FireFox1.0.6<br>
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"
src="http://www.google.co.uk/intl/en_uk/images/logo.gif">
</div>

<script>

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

function doOnload(){

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

addEvent(document.getElementById('myDiv2'),'mousem ove',function(){return
false;});
/*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');});
*/
}

addEvent(window,'load',doOnload);
</script>

Aug 5 '05 #1
1 2830
Mental
1
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Thomas | last post by:
Hi there, I have an iframe which is editable (designMode = "on") and want to resize it dynamically as the content grows (e.g. more lines of text is in there) and there the struggle starts. I...
4
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
2
by: philjhanna | last post by:
Hi, Does anyone know why I can't add return false with addEventListener in firefox (1.0.6). This demonstrates the problem If return false is added to onmousedown then you can drag over the...
6
by: rich_poppleton | last post by:
Help.... I've got a textarea where people type in a description. However for certain reasons we need to stop them typing !$*^ . I have a solution this which works fine in IE: function...
7
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the...
6
by: soulmach | last post by:
Using Firefox, I am trying to access a link within my HTML document, then use addEventListener() to add a click event to that link. I am using two external JS files. ajaxModal.js has the...
3
by: rahulgupta | last post by:
i have a textbox and a save_btn which is a hyperlink. when ever enter key is pressed there is a javascript which check if the name in the textbox contains any special characters. but when we press...
1
by: neovantage | last post by:
Hey all, I am using a PHP script which creates headings at run time in a sense at page execution. I am stuck a with a very little problem which i am sure i will have the solution from experts. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.