Click to See Complete Forum and Search --> : js - help me not mozilla


doppio
11-30-2004, 01:30 PM
hello,

i have ythis code, but not works in mozilla..please help me?...

*******
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0047)http://www.br1w.com/htmlit/rettangolo/index.htm -->
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<SCRIPT>
document.onselectstart = new Function("return true;");
document.ondragstart = new Function("return false;");
r_on = false;
x0=0;
y0=0;
x1=0;
y1=0;
iw=0;
ih=0;
il=0;
it=0;
bordo=1 *2;

function getPageCoords(element) {
// thanks to 'Martin Honnen' for this function
var coords = {x: 0, y: 0};
while (element) {
coords.x += element.offsetLeft;
coords.y += element.offsetTop;
element = element.offsetParent;
}
return coords;
}

function getMouseCoords(e) {
if(!e) e = window.event;
var coords = {x: 0, y: 0};
coords.x = e.x -1;
coords.y = e.y -1;
if(navigator.appName == "Netscape") {
coords.x += window.pageXOffset;
coords.y += window.pageYOffset;
}
if (navigator.appVersion.indexOf("MSIE") != -1){
if (navigator.appVersion.indexOf("Mac") == -1){
coords.x += document.body.scrollLeft;
coords.y += document.body.scrollTop;
}
}
return coords
}

function r_misura(obj) {
iw = obj.width;
ih = obj.height
p = getPageCoords(obj);
il = p.x;
it = p.y;
obj.alt='t='+it+' l='+il+' w='+iw+' h='+ih
}

function r_start(obj) {
p = getMouseCoords();
x0 = p.x -1;
y0 = p.y -1;
x1 = x0;
y1 = y0;
r_on = true;

d = document.re1.style;
d.top=y0;
d.left=x0;
d.height=0;
d.width=0;
d.display='none';
}

function r_move(obj) {
if (r_on) {
p = getMouseCoords()
x1 = p.x;
y1 = p.y;
// x1 = (x1<x0)?x1-1:x1;
// y1 = (y1<y0)?y1-1:y1;

d = document.re1.style;
// riordino e correggo le coordinate per l'immagine
ix0 = (x1<x0)?x1-1:x0;
iy0 = (y1<y0)?y1-1:y0;
ix1 = (x1>x0)?x1:x0;
iy1 = (y1>y0)?y1:y0;
// limito l'escursione
ix0 = (ix0<il)?il:ix0;
iy0 = (iy0<it)?it:iy0;
ix1 = (ix1>iw+il)?iw+il:ix1;
iy1 = (iy1>ih+it)?ih+it:iy1;
if (ix1-ix0>bordo && iy1-iy0>bordo) {
d.display=''
d.top=iy0;
d.left=ix0;
d.width=ix1-ix0-bordo;
d.height=iy1-iy0-bordo;
} else {
d.display='none'
}

f = document.misure;
f.myTop.value=y0-it;
f.myLeft.value=x0-il;
f.myBottom.value=y1-it;
f.myRight.value=x1-il;
f.myHeight.value=y1-y0;
f.myWidth.value=x1-x0;
}
}

function r_stop() {
r_on = false;
}

</SCRIPT>

<META content="MSHTML 5.50.4134.100" name=GENERATOR></HEAD>
<BODY bgColor=cyan><IMG onmouseup=r_stop(this) onmousemove=r_move(this)
onmousedown=r_start(this) src="index_file/image2.jpg" onload=r_misura(this)>
<IMG
style="BORDER-RIGHT: black 1px dotted; BORDER-TOP: black 1px dotted; DISPLAY: none; LEFT: 0px; BORDER-LEFT: black 1px dotted; BORDER-BOTTOM: black 1px dotted; POSITION: absolute; TOP: 0px"
src="index_file/ghost.gif" name=re1
NOonload="bordo=parseFloat(this.style.border)">
<HR>

<FORM name=misure>Top:<INPUT size=3 name=myTop> Left:<INPUT size=3 name=myLeft>
Bottom:<INPUT size=3 name=myBottom> Right:<INPUT size=3 name=myRight>
Height:<INPUT size=3 name=myHeight> Width:<INPUT size=3 name=myWidth> <INPUT onclick="x0=0;y0=0;document.re1.style.display='none'" type=reset value=Clear>
</FORM></BODY></HTML>

*********


thanks

Doppio

doppio
11-30-2004, 02:44 PM
Please...Nobody helps me to render it compatible with mozilla?

doppio
11-30-2004, 03:19 PM
I have modify the fuction but "e has not properties"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0047)http://www.br1w.com/htmlit/rettangolo/index.htm -->
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<SCRIPT>
document.onselectstart = new Function("return true;");
document.ondragstart = new Function("return false;");
r_on = false;
x0=0;
y0=0;
x1=0;
y1=0;
iw=0;
ih=0;
il=0;
it=0;
bordo=1 *2;

function getPageCoords (element) {
var coords = {x: 0, y: 0};
while (element) {
coords.x += element.offsetLeft;
coords.y += element.offsetTop;
element = element.offsetParent;
}
return coords;
}

function r_misura(obj) {
iw = obj.width;
ih = obj.height
p = getPageCoords(obj);
il = p.x;
it = p.y;
obj.alt='t='+it+' l='+il+' w='+iw+' h='+ih
}


function getMousePosition(e){
if(!e) e = window.event;
var coords = {x: 0, y: 0};
if(navigator.appName == "Netscape") {
coords.x = e.pageX + window.pageXOffset -1;
coords.y = e.pageY + window.pageYOffset -1;
} else {
coords.x = e.x -1;
coords.y = e.y -1;
}
if (navigator.appVersion.indexOf("MSIE") != -1){
if (navigator.appVersion.indexOf("Mac") == -1){
coords.x += document.body.scrollLeft;
coords.y += document.body.scrollTop;
}
}
alert(coords.x, coords.y);
//return coords
}


function r_start(obj) {
p = getMousePosition();
x0 = p.x -1;
y0 = p.y -1;
x1 = x0;
y1 = y0;
r_on = true;

d = document.re1.style;
d.top=y0;
d.left=x0;
d.height=0;
d.width=0;
d.display='none';
}

function r_move(obj) {
if (r_on) {
p = getMouseCoords()
x1 = p.x;
y1 = p.y;
// x1 = (x1<x0)?x1-1:x1;
// y1 = (y1<y0)?y1-1:y1;

d = document.re1.style;
// riordino e correggo le coordinate per l'immagine
ix0 = (x1<x0)?x1-1:x0;
iy0 = (y1<y0)?y1-1:y0;
ix1 = (x1>x0)?x1:x0;
iy1 = (y1>y0)?y1:y0;
// limito l'escursione
ix0 = (ix0<il)?il:ix0;
iy0 = (iy0<it)?it:iy0;
ix1 = (ix1>iw+il)?iw+il:ix1;
iy1 = (iy1>ih+it)?ih+it:iy1;
if (ix1-ix0>bordo && iy1-iy0>bordo) {
d.display=''
d.top=iy0;
d.left=ix0;
d.width=ix1-ix0-bordo;
d.height=iy1-iy0-bordo;
} else {
d.display='none'
}

f = document.misure;
f.myTop.value=y0-it;
f.myLeft.value=x0-il;
f.myBottom.value=y1-it;
f.myRight.value=x1-il;
f.myHeight.value=y1-y0;
f.myWidth.value=x1-x0;
}
}

function r_stop() {
r_on = false;
}

if(document.layers) document.captureEvents(Event.CLICK);
document.onclick=getMousePosition;
</SCRIPT>

<META content="MSHTML 5.50.4134.100" name=GENERATOR></HEAD>
<BODY bgColor=cyan><IMG onmouseup=r_stop(this) onmousemove=r_move(this)
onmousedown=r_start(this) src="index_file/image2.jpg" onload=r_misura(this)>
<IMG
style="BORDER-RIGHT: black 1px dotted; BORDER-TOP: black 1px dotted; DISPLAY: none; LEFT: 0px; BORDER-LEFT: black 1px dotted; BORDER-BOTTOM: black 1px dotted; POSITION: absolute; TOP: 0px"
src="index_file/ghost.gif" name=re1
NOonload="bordo=parseFloat(this.style.border)">
<HR>

<FORM name=misure>Top:<INPUT size=3 name=myTop> Left:<INPUT size=3 name=myLeft>
Bottom:<INPUT size=3 name=myBottom> Right:<INPUT size=3 name=myRight>
Height:<INPUT size=3 name=myHeight> Width:<INPUT size=3 name=myWidth> <INPUT onclick="x0=0;y0=0;document.re1.style.display='none'" type=reset value=Clear>
</FORM></BODY></HTML>


help me?..please...

thanks

Exuro
11-30-2004, 05:53 PM
Your code is a little bit of a big confusing mess... I tweaked your code and now it seems to work. The main problem seemed to be that you were passing the actual image in instead of the event in a few of your image event functions. I've attached the code I edited.

doppio
12-01-2004, 12:31 AM
thank you very much!!!

doppio
12-01-2004, 03:53 AM
hello,

i have tested the file in attachment (see messages up), on explorer works perfectly,
on mozilla works but if i insert a large image and scroll the page to the bottom, it doesn't respect the mouse coords..

please help me

ps
excuseme for English

Exuro
12-01-2004, 05:57 PM
Originally posted by doppio
on mozilla works but if i insert a large image and scroll the page to the bottom, it doesn't respect the mouse coords..
What exactly do you mean by that? What's happening?

doppio
12-02-2004, 12:26 AM
hello,

exactly descrit must select an area with mouse and must take the coords and domensions of selected area, but this script when I scrool the page not work..

thamks

Exuro
12-02-2004, 01:52 PM
Okay, I think it's all fixed now.

doppio
12-02-2004, 02:02 PM
thank you very much !!!!

Exuro
12-02-2004, 04:28 PM
You're welcome!

doppio
12-02-2004, 05:57 PM
why

f.myTop.value=y0+":"+it;

this line wite in TOP field 123:E..

if i remove ":+it" is a problem?..

thanks..

hello
Manuele

Exuro
12-02-2004, 06:54 PM
Oh, I'm sorry. I edited that for debugging purposes. It should be this:
f.myTop.value=y0+it;

doppio
12-03-2004, 12:26 AM
okay thank you very much!