Easy Tutorial
❮ Prop Style Borderimagerepeat Prop Select Name ❯

Window self Property


Definition and Usage

The self property returns a reference to the current window object. This property ensures that functions or properties within the current window are correctly called without confusion, even when multiple windows are open.

The self property is read-only.

Syntax

Note: window, self, and window.self are equivalent.


Browser Support

Property
self Yes Yes Yes Yes Yes

Example

When the "Check Window" button is clicked, the check() function is called to check the current window's status and determine if it is in the top-level window:

function check(){
    if (window.top != window.self) {
        document.write("<p>This window is not the top-level window! Am I in a frame?</p>");
    } else {
        document.write("<p>This window is the top-level window!</p>");
    }
}

❮ Prop Style Borderimagerepeat Prop Select Name ❯