X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Window self Property

Window Object Reference Window Object

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! Am I in a frame?";
    } else {
        document.getElementById("demo").innerHTML = "This window is the topmost window!";
    }
}

Try it yourself »


Definition and Usage

The self property returns the current window.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The self property is supported in all major browsers.


Syntax

window.self

Technical Details

Return Value: A reference to the window object itself


Window Object Reference Window Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook