IFrame src Property - Get the URL of the document that is shown in an iframe: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:IFrame

Description

IFrame src Property - Get the URL of the document that is shown in an iframe:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<iframe id="myFrame" srcdoc="<p>Hello world!</p>" src="http://java2s.com"></iframe>

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

<script>
function myFunction() {/*from w  ww.ja  va 2  s  .c  o m*/
    var v = document.getElementById("myFrame").src;
    console.log(v);
}
</script>

</body>
</html>

Related Tutorials