...

View Full Version : Whats the difference between event.screen, eventclient, eventoffset, and event.x?



SpiritualStorms
10-28-2004, 08:14 AM
I was at the following site,
http://www.w3schools.com/dhtml/dhtml_object_event.asp

and basically, i was going through the explanations of what each event meant, and to be honest, they all seemed the same to me. I hardly see any real difference between all the following:

On the screenX, and screenY:

function coordinates()
{
x=event.screenX
y=event.screenY
alert("X=" + x + " Y=" + y)
}

On the clientX, and clientY:

function show_coords()
{
x=event.clientX
y=event.clientY
alert("X coords: " + x + ", Y coords: " + y)
}


On the X, and Y, coordinates:

function coordinates()
{
x=event.x
y=event.y
alert("X=" + x + " Y=" + y)
}


The offsetX, and offsetY, coordinates:

function coordinates()
{
x=event.offsetX
y=event.offsetY
alert("Horizontal=" + x + " Vertical=" + y)
}

To be perfectly honest, they all seemed to report the same thing when you put any of the codes in an actual page. I didnt see any difference really between any of the above, other than, they had different names.

jbot
10-28-2004, 10:38 AM
some are Moz only, some are IE only. not sure where standards come in (use object detection and you'll be fine). some pertain to position in relation to window, whilst others relate to position in relation to containing element.

Roy Sinclair
10-28-2004, 05:17 PM
Some of those events are specific to the browser window while others are specific to the document, test them and then scroll the page down a ways and test them again to see the difference.

SpiritualStorms
10-29-2004, 04:01 AM
from jbot:

some are Moz only, some are IE only. not sure where standards come in (use object detection and you'll be fine). some pertain to position in relation to window, whilst others relate to position in relation to containing element.



from Roy

Some of those events are specific to the browser window while others are specific to the document, test them and then scroll the page down a ways and test them again to see the difference.

I dont "suppose" either of you could point to links that would make a comparison distinction between the 2?

As i said, i got most of the codes from the W3scools website. They didnt go too in depth in the differences between the 2 main browsers.

fci
10-29-2004, 04:44 AM
http://www.webdevelopersjournal.com/articles/jsevents3/jsevents3.html


clientX Mouse pointer X coordinate relative to window
clientY Mouse pointer Y coordinate relative to window
offsetX Mouse pointer X coordinate relative to element that fired the event
offsetY Mouse pointer Y coordinate relative to element that fired the event

SpiritualStorms
10-29-2004, 10:46 AM
I checked out the site. Wasnt bad. The only real difference that i found was that offSet works in relation to the over-all area of something like a block, or a layer, and i would presume, a table. Here's the example used:

http://www.webdevelopersjournal.com/articles/jsevents3/Offsets.htm

According to the source code of that site, this is all that was really said:


<HTML>
<HEAD>
<TITLE>Offsets</TITLE>

<SCRIPT>

function statusreport() {
status = 'offsetX : ' + event.offsetX +' , offsetY : ' + event.offsetY;
}

</SCRIPT>
</HEAD>

<BODY>
<DIV onmousemove="statusreport();" style="position:absolute;top:100;left:100;height:200;width:200;background-color:blue"></DIV>
</BODY>
</HTML>


It didnt much talk about x, y, and screenY, and screenX. If either of the aforementioned properties relate to anything other than IE, it was not stated on the link given.

There was another example though that sort of confused me. There was one example that tried to juxstapose the difference between clientX, and offSetX, but from what i saw, neither really differed from the other. One would have thought that the minute one stepped outside the bounding box, that the coordinate registration would stop for one property, but not for the other. This wasnt the case though. Even when i made circles with the cursor in the area outside the blue box, the status window still reflected changes in the messages associated with a particular property. I found that odd.

Here is the exact example:

http://www.webdevelopersjournal.com/articles/jsevents3/Offsets2.htm

Well, maybe later this week i will figure something out. MSDN has a lot of interesting methods, objects, and properties.

jbot
10-29-2004, 11:00 AM
It didnt much talk about x, y, and screenY, and screenX. If either of the aforementioned properties relate to anything other than IE, it was not stated on the link given.

these are Netscape-only properties. i would point you to Devedge, but as well know, those AOL twats removed it. you could always google tho* ;)

*the internet is great

fci
10-29-2004, 11:18 AM
these are Netscape-only properties. i would point you to Devedge, but as well know, those AOL twats removed it. you could always google tho* ;)

*the internet is great

go here to save googling:
http://www.codingforums.com/showthread.php?t=46294



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum