Get IFrame Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:IFrame

Introduction

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>
<html>
<body>

<iframe id="myFrame" src="http://java2s.com"></iframe>

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

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

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

</body>
</html>

Related Tutorials