Window frameElement Property - Javascript Browser Object Model

Javascript examples for Browser Object Model:Window frameElement


The frameElement property returns the <iframe> element in which the current window is inserted.

If the document window is not placed within an <iframe>, the return value of this property is null.

This property is read-only.

Return Value

An IFrame object, which is the host of the current window, otherwise null

The following code shows how to check if the current window is in an <iframe>. If so, change its URL to "":

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">Test</button>

function myFunction() {/*from  w  ww .j  av  a2s. co  m*/
    var frame = window.frameElement;

    if (frame) {
        frame.src = "";


Related Tutorials