screenLeft, screenX, screenTop, screenY

In this chapter you will learn:

  1. How to get window location

Window location

The following code determines the left and top positions of the window across browsers:

<!DOCTYPE HTML> <!-- jav  a 2s . c om-->
<html> 
<body> 
<script type="text/javascript"> 
var leftPos = (typeof window.screenLeft == "number") ? 
                     window.screenLeft : 
                     window.screenX; 
var topPos = (typeof window.screenTop == "number") ? 
                     window.screenTop : 
                     window.screenY; 
document.writeln(leftPos);
document.writeln(topPos);


</script> 
</body> 
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. How to use timer in Javascript
  2. How to clear a timer
Home » Javascript Tutorial » Window
Window Object
alert()
close()
confirm()
find()
Window height and width
location
window.moveBy
window.moveTo
window.open()
window.print()
window.prompt()
resizeTo(x,y) and resizeBy(xDelta,yDelta)
window.scrollTo(x,y)
screenLeft, screenX, screenTop, screenY
setInterval()
setTimeout()