Change the name of an iframe:
document.getElementById("myFrame").name = "newIframeName";
Click the button to change the name of the iframe.
<!DOCTYPE html> <html> <body> <iframe id="myFrame" src="https://www.java2s.com" name="iframe_a"></iframe> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w.j a v a 2 s . c om document.getElementById("myFrame").name = "newIframeName"; document.getElementById("demo").innerHTML = "The name of the iframe was changed."; } </script> </body> </html>