JavaScript – Getting Current Window Position

Using JavaScript I need to get the current window position.  For example I have the following html page:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "">
<html xmlns="" >
    <title>Sample App</title>

    <script language="javascript" type="text/javascript">
    function myOnClick()
         var x;
         var y;
          // these are just dummy values, I need to get the actual window position
          x = 1;
          y = 2;

           // Report the results
           alert("Window is at " + x + ", " + y);  

<body onclick="myOnClick()">
    <div>This is my App!</div>


In the function myOnClick  I would like to assign the current window position to the variables x and y.  I am using Microsoft Internet Explorer 6.0.  Anybody have any suggestions?

Who is Participating?
try the properties: window.screenLeft and window.screenTop.
stminfoAuthor Commented:
Works great, thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.