Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-28-2004, 07:14 AM   PM User | #1
SpiritualStorms
Regular Coder

 
Join Date: Dec 2003
Location: America
Posts: 544
Thanks: 0
Thanked 0 Times in 0 Posts
SpiritualStorms is an unknown quantity at this point
Whats the difference between event.screen, eventclient, eventoffset, and event.x?

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:
Code:
function coordinates()
{
x=event.screenX
y=event.screenY
alert("X=" + x + " Y=" + y)
}
On the clientX, and clientY:
Code:
function show_coords()
{
x=event.clientX
y=event.clientY
alert("X coords: " + x + ", Y coords: " + y)
}
On the X, and Y, coordinates:
Code:
function coordinates()
{
x=event.x
y=event.y
alert("X=" + x + " Y=" + y)
}
The offsetX, and offsetY, coordinates:
Code:
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.
__________________
LovesWar
SpiritualStorms is offline   Reply With Quote
Old 10-28-2004, 09:38 AM   PM User | #2
jbot
Senior Coder

 
Join Date: Feb 2004
Location: Edinburgh
Posts: 1,352
Thanks: 0
Thanked 0 Times in 0 Posts
jbot is an unknown quantity at this point
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.
__________________
*keep it simple (TM)
jbot is offline   Reply With Quote
Old 10-28-2004, 04:17 PM   PM User | #3
Roy Sinclair
Senior Coder

 
Join Date: Jun 2002
Location: Wichita
Posts: 3,880
Thanks: 0
Thanked 0 Times in 0 Posts
Roy Sinclair will become famous soon enough
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.
__________________
Check out the Forum Search. It's the short path to getting great results from this forum.
Roy Sinclair is offline   Reply With Quote
Old 10-29-2004, 03:01 AM   PM User | #4
SpiritualStorms
Regular Coder

 
Join Date: Dec 2003
Location: America
Posts: 544
Thanks: 0
Thanked 0 Times in 0 Posts
SpiritualStorms is an unknown quantity at this point
Quote:
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.
Quote:
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.
__________________
LovesWar
SpiritualStorms is offline   Reply With Quote
Old 10-29-2004, 03:44 AM   PM User | #5
fci
Senior Coder

 
Join Date: Aug 2004
Location: Twin Cities
Posts: 1,345
Thanks: 0
Thanked 0 Times in 0 Posts
fci is an unknown quantity at this point
http://www.webdevelopersjournal.com/...jsevents3.html
Code:
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
fci is offline   Reply With Quote
Old 10-29-2004, 09:46 AM   PM User | #6
SpiritualStorms
Regular Coder

 
Join Date: Dec 2003
Location: America
Posts: 544
Thanks: 0
Thanked 0 Times in 0 Posts
SpiritualStorms is an unknown quantity at this point
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/...s3/Offsets.htm

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

Code:
<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/...3/Offsets2.htm

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

Last edited by SpiritualStorms; 10-29-2004 at 09:50 AM..
SpiritualStorms is offline   Reply With Quote
Old 10-29-2004, 10:00 AM   PM User | #7
jbot
Senior Coder

 
Join Date: Feb 2004
Location: Edinburgh
Posts: 1,352
Thanks: 0
Thanked 0 Times in 0 Posts
jbot is an unknown quantity at this point
Quote:
Originally Posted by SpiritualStorms
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
__________________
*keep it simple (TM)
jbot is offline   Reply With Quote
Old 10-29-2004, 10:18 AM   PM User | #8
fci
Senior Coder

 
Join Date: Aug 2004
Location: Twin Cities
Posts: 1,345
Thanks: 0
Thanked 0 Times in 0 Posts
fci is an unknown quantity at this point
Quote:
Originally Posted by jbot
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
fci is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:40 PM.


Advertisement
Log in to turn off these ads.