Get IFrame Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:IFrame


The IFrame object represents an HTML <iframe> element.

You can access an <iframe> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<iframe id="myFrame" src=""></iframe>

<button onclick="myFunction()">get the URL of the iframe</button>

<p id="demo"></p>

function myFunction() {//  www.  ja  v  a  2  s . c  o  m
    var x = document.getElementById("myFrame").src;
    document.getElementById("demo").innerHTML = x;


Related Tutorials