473,659 Members | 3,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with firefox/Netscape rectangle-over-image please

Hi

I have an application that draws a selection rectangle over a map
image. I can get it to work fine in IE and Opera, but not
Firefox/Netscape.

I've thrown the following small example together to illustrate the
problem - the problem being that FF/NE initially draw my rectangle
before the icon changes immediately to the black no-entry icon. Then,
when I let go of the mouse, the rectangle continues drawing, but it
doesn't stop as the mouseup has already fired of course.

IE was doing the same, but I found the ondragstart/cancelDragDrop
solution to that. I can't find what appears to be a similar solution
for FF/NE.

Any advice very gratefully received! Hair is fading fast :)

<HTML>
<HEAD>
<META http-equiv=imagetool bar content=no>
<TITLE>

</TITLE>
<STYLE>
#rubberBand {
position: absolute;
visibility: hidden;
width: 0px; height: 0px;
border: 2px dashed red;
}
</STYLE>

</HEAD>
<BODY>
<img name="myImage" id="myImage" src="myimage.gi f" height=400
width=400>
<DIV ID="rubberBand" ></DIV>

<SCRIPT>

var IMG;

function startRubber (evt) {
if (document.all) {
// IE
var r = document.all.ru bberBand;
r.style.width = 0;
r.style.height = 0;
r.style.pixelLe ft = event.x;
r.style.pixelTo p = event.y;
r.style.visibil ity = 'visible';
IMG.ondragstart = cancelDragDrop; // otherwise IE will try to drag
the image
}
else if (document.getEl ementById) {
// firefox
var r = document.getEle mentById('rubbe rBand');
r.style.width = 0;
r.style.height = 0;
r.style.left = evt.clientX + 'px';
r.style.top = evt.clientY + 'px';
r.style.visibil ity = 'visible';
}
IMG.onmousemove = moveRubber;
}
function moveRubber (evt) {
if (document.all) { // IE
var r = document.all.ru bberBand;
r.style.width = event.x - r.style.pixelLe ft;
r.style.height = event.y - r.style.pixelTo p;
}
else if (document.getEl ementById) { // firefox
var r = document.getEle mentById('rubbe rBand');
r.style.width = evt.clientX - parseInt(r.styl e.left);
r.style.height = evt.clientY - parseInt(r.styl e.top);
}
return false; // otherwise IE won't fire mouseup :/
}
function stopRubber (evt) {
IMG.onmousemove = null;
}

function cancelDragDrop( )
{
window.event.re turnValue = false;
}

IMG = document.getEle mentById('myIma ge');
IMG.onmousedown = startRubber;
IMG.onmouseup = stopRubber;

</SCRIPT>
</BODY>
</HTML>

Aug 17 '05 #1
2 5357

AndrewW wrote:
Hi

I have an application that draws a selection rectangle over a map
image. I can get it to work fine in IE and Opera, but not
Firefox/Netscape.

I've thrown the following small example together to illustrate the
problem - the problem being that FF/NE initially draw my rectangle
before the icon changes immediately to the black no-entry icon. Then,
when I let go of the mouse, the rectangle continues drawing, but it
doesn't stop as the mouseup has already fired of course.

IE was doing the same, but I found the ondragstart/cancelDragDrop
solution to that. I can't find what appears to be a similar solution
for FF/NE.

Any advice very gratefully received! Hair is fading fast :)

<HTML>
<HEAD>
<META http-equiv=imagetool bar content=no>
<TITLE>

</TITLE>
<STYLE>
#rubberBand {
position: absolute;
visibility: hidden;
width: 0px; height: 0px;
border: 2px dashed red;
}
</STYLE>

</HEAD>
<BODY>
<img name="myImage" id="myImage" src="myimage.gi f" height=400
width=400>
<DIV ID="rubberBand" ></DIV>

<SCRIPT>

var IMG;

function startRubber (evt) {
if (document.all) {
// IE
var r = document.all.ru bberBand;
r.style.width = 0;
r.style.height = 0;
r.style.pixelLe ft = event.x;
r.style.pixelTo p = event.y;
r.style.visibil ity = 'visible';
IMG.ondragstart = cancelDragDrop; // otherwise IE will try to drag
the image
}
else if (document.getEl ementById) {
// firefox
var r = document.getEle mentById('rubbe rBand');
r.style.width = 0;
r.style.height = 0;
r.style.left = evt.clientX + 'px';
r.style.top = evt.clientY + 'px';
r.style.visibil ity = 'visible';
}
IMG.onmousemove = moveRubber;
}
function moveRubber (evt) {
if (document.all) { // IE
var r = document.all.ru bberBand;
r.style.width = event.x - r.style.pixelLe ft;
r.style.height = event.y - r.style.pixelTo p;
}
else if (document.getEl ementById) { // firefox
var r = document.getEle mentById('rubbe rBand');
r.style.width = evt.clientX - parseInt(r.styl e.left);
r.style.height = evt.clientY - parseInt(r.styl e.top);
}
return false; // otherwise IE won't fire mouseup :/
}
function stopRubber (evt) {
IMG.onmousemove = null;
}

function cancelDragDrop( )
{
window.event.re turnValue = false;
}

IMG = document.getEle mentById('myIma ge');
IMG.onmousedown = startRubber;
IMG.onmouseup = stopRubber;

</SCRIPT>
</BODY>
</HTML>


Can anyone assist with this? It can't be impossible, but I can't work
out where it's going wrong.

Help very gratefully received, thanks in advance.

AW

Aug 22 '05 #2
Anyone ? I really need to get this issue sorted quickly.

Thanks
AW

AndrewW wrote:
Hi

I have an application that draws a selection rectangle over a map
image. I can get it to work fine in IE and Opera, but not
Firefox/Netscape.

I've thrown the following small example together to illustrate the
problem - the problem being that FF/NE initially draw my rectangle
before the icon changes immediately to the black no-entry icon. Then,
when I let go of the mouse, the rectangle continues drawing, but it
doesn't stop as the mouseup has already fired of course.

IE was doing the same, but I found the ondragstart/cancelDragDrop
solution to that. I can't find what appears to be a similar solution
for FF/NE.

Any advice very gratefully received! Hair is fading fast :)

<HTML>
<HEAD>
<META http-equiv=imagetool bar content=no>
<TITLE>

</TITLE>
<STYLE>
#rubberBand {
position: absolute;
visibility: hidden;
width: 0px; height: 0px;
border: 2px dashed red;
}
</STYLE>

</HEAD>
<BODY>
<img name="myImage" id="myImage" src="myimage.gi f" height=400
width=400>
<DIV ID="rubberBand" ></DIV>

<SCRIPT>

var IMG;

function startRubber (evt) {
if (document.all) {
// IE
var r = document.all.ru bberBand;
r.style.width = 0;
r.style.height = 0;
r.style.pixelLe ft = event.x;
r.style.pixelTo p = event.y;
r.style.visibil ity = 'visible';
IMG.ondragstart = cancelDragDrop; // otherwise IE will try to drag
the image
}
else if (document.getEl ementById) {
// firefox
var r = document.getEle mentById('rubbe rBand');
r.style.width = 0;
r.style.height = 0;
r.style.left = evt.clientX + 'px';
r.style.top = evt.clientY + 'px';
r.style.visibil ity = 'visible';
}
IMG.onmousemove = moveRubber;
}
function moveRubber (evt) {
if (document.all) { // IE
var r = document.all.ru bberBand;
r.style.width = event.x - r.style.pixelLe ft;
r.style.height = event.y - r.style.pixelTo p;
}
else if (document.getEl ementById) { // firefox
var r = document.getEle mentById('rubbe rBand');
r.style.width = evt.clientX - parseInt(r.styl e.left);
r.style.height = evt.clientY - parseInt(r.styl e.top);
}
return false; // otherwise IE won't fire mouseup :/
}
function stopRubber (evt) {
IMG.onmousemove = null;
}

function cancelDragDrop( )
{
window.event.re turnValue = false;
}

IMG = document.getEle mentById('myIma ge');
IMG.onmousedown = startRubber;
IMG.onmouseup = stopRubber;

</SCRIPT>
</BODY>
</HTML>


Aug 30 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
5017
by: Geoff | last post by:
When trying to focus a field in Firefox, I get the following error: Error: " nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame :: file:///C:/Documents%20and%20Settings/Edd/Desktop/test.html :: valText :: line 24" data: no] Source File: file:///C:/Documents%20and%20Settings/Edd/Desktop/test.html Line: 24 Anyone have any ideas as to why this is happening?
6
1986
by: christian9997 | last post by:
Hi I would be very helpful if someone could help me with this code. It works fine in IE but when I display it in Netscape or Firefox and I move the mouse from one menu to the other the gap between the two menus gets bigger. What is the cause of this? Thanks CODE:
1
2141
by: RC | last post by:
I know DTD (Document Type Definition) is supported by Netscape/Firefox and IE. But I typed some examples from http://www.w3schools.com/schema/default.asp Seems no effect on those browsers.
6
2233
by: msuk | last post by:
All, I have created some ASP.NET/C# webpages that displays pefectly in internet explorer 6.0 but when I use Firefox 1.0 and Netscape 7.1 the page does not display correctly i.e the text and text boxes for example dont line up they are smaller in size. Does anyone now why this is happening and how I can make it look as it does in IE6.0
3
1224
by: Arne | last post by:
I have a dropdownlist/select box with an autopostback to code behind. It works great in Internet Explorer, but doesn't work in Netscape and Firefox. What kind of support does ASP.net promise for Netscape and Firefox?
1
2589
by: Jordan | last post by:
I set the cursor property to change to the "hand" when the user performs an "onmouseover" event on a hyperlink object. This does work correctly with Internet Explorer, however, with Netscape and Firefox, the cursor is just the "vertical line." Does anyone know why this isn't working with Netscape or Firefox? Thanks!
15
1731
by: Viken Karaguesian | last post by:
Hello all, Just a curiosity question here. Since Firefox and Netscape are both based on the Mozilla engine (AFAIK), can I assume that they will display my pages the same way? Viken K. --
5
3111
by: SPE - Stani's Python Editor | last post by:
Hi, During optimizing SPE for Ubuntu, I found something strange. I have Ubuntu 5.10 "The Breezy Badger" and unfortunately this code is not working: >>> import webbrowser >>> webbrowser.open("http://www.python.org") It does not throw an exception, but is not able to launch a browser.
5
2767
by: Martijn Saly | last post by:
I'd like to test in my script, if it's going to be possible to enable priviliges. If I use this... netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect") ....it presents a dialog to the user asking if it's ok. Now I don't want to hide that dialog, I'd like to know if it's going to be possible to click the Allow button, before ever making this call. Basically I need
4
1741
by: drclue | last post by:
I've this SVG speaker selection tool I've been working on and it validates with the w3.org. I'd like to see what it does for a few real users here. http://kirksaeter.com/SpeakerSelector/SpeakerSelector.html http://kirksaeter.com/SpeakerSelector/Assets/Images/SpeakerSelector.svg
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8337
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8531
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8628
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6181
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.