Javascript examples for DOM HTML Element:IFrame
The src property sets or gets the src attribute in an iframe element, which controls the URL of the document to show in an iframe.
Set the src property with the following Values
Value | Description |
---|---|
URL | Sets the URL of the document to embed in the iframe. |
Possible values:
A String, representing the URL of the document that is embedded in the iframe.
The following code shows how to change the URL of the document to embed in the iframe:
<!DOCTYPE html> <html> <body> <iframe id="myFrame" src="#"></iframe> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from ww w . j a va 2 s .c o m*/ document.getElementById("myFrame").src = "http://www.java2s.com"; } </script> </body> </html>