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.
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 "java2s.com":
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from w ww .j av a2s. co m*/ var frame = window.frameElement; if (frame) { frame.src = "https://www.java2s.com/"; } } </script> </body> </html>