Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Window screenLeft and screenTop properties

Window screenLeft and screenTop properties

Window Object Reference Window Object


Definition and Usage

The screenLeft and screenTop properties return the X and Y coordinates of the window relative to the screen.

Syntax

window.screenLeft

window.screenTop


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the screenLeft and screenTop properties, except Firefox.

Note: For the Firefox browser, please use "window.screenX" and "window.screenY".


Example

Example

Return the X and Y coordinates of the new window relative to the screen:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>

Runoob Tutorial(runoob.com)

title

<script function openWin(){myWindow=window>

.

open

(

'

'

,

'

'

)

;

myWindow

.

document

.

write

(

"

This is 'my window'

"

)

;

myWindow

.

document

.

write

(

"


ScreenLeft:

"

myWindow

.

screenLeft

)

;

myWindow

.

document

.

write

(

"


ScreenTop:

"

myWindow

.

screenTop

"

"

)

;

}

script

head

<body>
<input type="button" value=">

Open 'My Window'

"

onclick

=

"

openWin()

"

body

html

Try it »


Window Object Reference Window Object