We help IT Professionals succeed at work.

JavaScript – Getting Current Window Position

stminfo
stminfo asked
on
Medium Priority
2,256 Views
Last Modified: 2012-05-05
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"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <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);  
     }    
   
     </script>

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

--------------------------------------------------------

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?

Thanks
Comment
Watch Question

Commented:
try the properties: window.screenLeft and window.screenTop.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Works great, thanks!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.