Solved

# How to show the current x,y coordinate?

Posted on 2001-06-15
268 Views
I would like to get the xy coordinate of the current screen relative to the whole page.....how can i do that?
Actually I need this because I want to do a floating frame which will follow the screen as you scroll.  So what I am gonna do is get teh xy coordinate of the current screen.....and then set the iframe to the position.  Are there any other way that I don't need to get the xy coordinate of the current screen? Just like I can set the position relative to the current screen?
Plz help....thx
0
Question by:armansiu
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 4
• 2

LVL 9

Accepted Solution

nimaig earned 200 total points
ID: 6195622
Check this

<html>
<script language="javascript">
<!--
function getXY(){
if (window.pageXOffset > -1) {
x = window.pageXOffset;
y = window.pageYOffset;
} else if (document.body) {
x = window.document.body.scrollLeft;
y = window.document.body.scrollTop;
}
}
//-->
</script>

<body leftmargin=5 topmargin=0>
<form>
Hello .......... testing ............
<input type="button" value=" Click " onClick="getXY()">
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<input type="button" value=" Click " onClick="getXY()">
<table width="200%">
<tr><td align="right" width="200%"><input type="button" value=" Click " onClick="getXY()"></td></tr>
</table>

</form>
</body>
</html>
0

LVL 9

Expert Comment

ID: 6195638
You can get similar example. It is of floating logo. You can modify as per your requirement :

http://www.dynamicdrive.com/dynamicindex4/logo.htm
0

Author Comment

ID: 6195683
but why we need that if statement?
and what's the difference between scrollLeft and pageXOffset?
0

LVL 9

Expert Comment

ID: 6195707
That is to make it work in Netscape
0

LVL 9

Expert Comment

ID: 6195711
That is to make it work in Netscape
0

Author Comment

ID: 6195720
Thanks so much =)
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…