Window self property
Definition and Usage
self property returns a read-only reference to the window itself.
grammar
window.self
Browser Support
All major browsers support self property
Examples
Examples
When click "Check window" button, check () is called, and check the current state of the window:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Script>
function check () {
if (window.top! = window.self) {
document.write ( "<p> This window is not the topmost window! I'm in a frame? </ p>")
}
else {
document.write ( "<p> This window is the topmost window! </ p>")
}
}
</ Script>
</ Head>
<Body>
<Input type = "button" onclick = "check ()" value = "check window">
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Script>
function check () {
if (window.top! = window.self) {
document.write ( "<p> This window is not the topmost window! I'm in a frame? </ p>")
}
else {
document.write ( "<p> This window is the topmost window! </ p>")
}
}
</ Script>
</ Head>
<Body>
<Input type = "button" onclick = "check ()" value = "check window">
</ Body>
</ Html>
try it"
Window object