Window self property
Window Object
Definition and Usage
The self property returns a reference to the current window object. Using this property, you can correctly call functions or properties within the current window without confusion even when multiple windows are open.
The self property is read-only.
Syntax
window.self
**Note:** window, self, and window.self are equivalent.
Browser support
| property | |||||
|---|---|---|---|---|---|
| self | Yes | Yes | Yes | Yes | Yes |
Example
Example
When the "Check Window" button is clicked, check() is called to check the state of the current window and determine whether it is the top-level window:
function
check
(
)
{
if
(
window
.
top
!=
window
.
self
)
{
document
.
write
(
"
This window is not the top-level window! Am I in a frame?
"
)
}
else
{
document
.
write
(
"
This window is the top-level window!
"
)
}
}
Try it »
Window Object