IFrame name Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:IFrame


The name property sets or gets the name attribute in an iframe element.

Set the name property with the following Values

Value Description
name The name of the iframe

Return Value

A String, representing the name of the iframe

The following code shows how to get the name of an iframe:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

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

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

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

function myFunction() {/*from w  ww .  ja  v  a2s  .c  o  m*/
    var v = document.getElementById("myFrame").name;
    document.getElementById("demo").innerHTML = v;


Related Tutorials