473,320 Members | 1,945 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,320 software developers and data experts.

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=imagetoolbar 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.gif" height=400
width=400>
<DIV ID="rubberBand"></DIV>

<SCRIPT>

var IMG;

function startRubber (evt) {
if (document.all) {
// IE
var r = document.all.rubberBand;
r.style.width = 0;
r.style.height = 0;
r.style.pixelLeft = event.x;
r.style.pixelTop = event.y;
r.style.visibility = 'visible';
IMG.ondragstart = cancelDragDrop; // otherwise IE will try to drag
the image
}
else if (document.getElementById) {
// firefox
var r = document.getElementById('rubberBand');
r.style.width = 0;
r.style.height = 0;
r.style.left = evt.clientX + 'px';
r.style.top = evt.clientY + 'px';
r.style.visibility = 'visible';
}
IMG.onmousemove = moveRubber;
}
function moveRubber (evt) {
if (document.all) { // IE
var r = document.all.rubberBand;
r.style.width = event.x - r.style.pixelLeft;
r.style.height = event.y - r.style.pixelTop;
}
else if (document.getElementById) { // firefox
var r = document.getElementById('rubberBand');
r.style.width = evt.clientX - parseInt(r.style.left);
r.style.height = evt.clientY - parseInt(r.style.top);
}
return false; // otherwise IE won't fire mouseup :/
}
function stopRubber (evt) {
IMG.onmousemove = null;
}

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

IMG = document.getElementById('myImage');
IMG.onmousedown = startRubber;
IMG.onmouseup = stopRubber;

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

Aug 17 '05 #1
2 5339

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=imagetoolbar 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.gif" height=400
width=400>
<DIV ID="rubberBand"></DIV>

<SCRIPT>

var IMG;

function startRubber (evt) {
if (document.all) {
// IE
var r = document.all.rubberBand;
r.style.width = 0;
r.style.height = 0;
r.style.pixelLeft = event.x;
r.style.pixelTop = event.y;
r.style.visibility = 'visible';
IMG.ondragstart = cancelDragDrop; // otherwise IE will try to drag
the image
}
else if (document.getElementById) {
// firefox
var r = document.getElementById('rubberBand');
r.style.width = 0;
r.style.height = 0;
r.style.left = evt.clientX + 'px';
r.style.top = evt.clientY + 'px';
r.style.visibility = 'visible';
}
IMG.onmousemove = moveRubber;
}
function moveRubber (evt) {
if (document.all) { // IE
var r = document.all.rubberBand;
r.style.width = event.x - r.style.pixelLeft;
r.style.height = event.y - r.style.pixelTop;
}
else if (document.getElementById) { // firefox
var r = document.getElementById('rubberBand');
r.style.width = evt.clientX - parseInt(r.style.left);
r.style.height = evt.clientY - parseInt(r.style.top);
}
return false; // otherwise IE won't fire mouseup :/
}
function stopRubber (evt) {
IMG.onmousemove = null;
}

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

IMG = document.getElementById('myImage');
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=imagetoolbar 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.gif" height=400
width=400>
<DIV ID="rubberBand"></DIV>

<SCRIPT>

var IMG;

function startRubber (evt) {
if (document.all) {
// IE
var r = document.all.rubberBand;
r.style.width = 0;
r.style.height = 0;
r.style.pixelLeft = event.x;
r.style.pixelTop = event.y;
r.style.visibility = 'visible';
IMG.ondragstart = cancelDragDrop; // otherwise IE will try to drag
the image
}
else if (document.getElementById) {
// firefox
var r = document.getElementById('rubberBand');
r.style.width = 0;
r.style.height = 0;
r.style.left = evt.clientX + 'px';
r.style.top = evt.clientY + 'px';
r.style.visibility = 'visible';
}
IMG.onmousemove = moveRubber;
}
function moveRubber (evt) {
if (document.all) { // IE
var r = document.all.rubberBand;
r.style.width = event.x - r.style.pixelLeft;
r.style.height = event.y - r.style.pixelTop;
}
else if (document.getElementById) { // firefox
var r = document.getElementById('rubberBand');
r.style.width = evt.clientX - parseInt(r.style.left);
r.style.height = evt.clientY - parseInt(r.style.top);
}
return false; // otherwise IE won't fire mouseup :/
}
function stopRubber (evt) {
IMG.onmousemove = null;
}

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

IMG = document.getElementById('myImage');
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
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 ::...
6
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...
1
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
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...
3
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...
1
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...
15
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
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 >>>...
5
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...
4
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. ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.