Window self Property
Example
When the "Check window" button is clicked, the function check() is called and the current window status is checked. If the topmost window (window.top) is different from the current window (window.self), then output that "This window is not the topmost window! Am I in a frame?". If the topmost window equals the current window, then fire the else statement:
function myFunction() {
if (window.top != window.self) {
document.getElementById("demo").innerHTML = "This window is NOT the topmost window!";
} else {
document.getElementById("demo").innerHTML = "This window is the topmost window!";
}
}
if (window.top != window.self) {
document.getElementById("demo").innerHTML = "This window is NOT the topmost window!";
} else {
document.getElementById("demo").innerHTML = "This window is the topmost window!";
}
}
Try it yourself »
Definition and Usage
The self property returns the current window.
The self property is often used in comparisons (like in the example above).
This property is read-only.
Syntax
window.self
Technical Details
Return Value: | A reference to the Window object itself |
---|
source - http://www.w3schools.com/jsref/prop_win_self.asp
'Development > JavaScript' 카테고리의 다른 글
javascript - IIFE, Module (0) | 2018.01.02 |
---|---|
javascript - How to merge two arrays in Javascript and de-duplicate items (0) | 2015.08.30 |
javaScript - Data Types (0) | 2015.07.11 |
javascript - How does this JavaScript/JQuery Syntax work: (function( window, undefined ) { })(window)? (0) | 2015.07.11 |
javascript - objects (0) | 2015.07.11 |