Return the width of an iframe:
var x = document.getElementById("myFrame").width;
Click the button to display the width of the iframe.
<!DOCTYPE html> <html> <body> <iframe id="myFrame" src="https://www.java2s.com" height="200" width="250"></iframe> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from ww w.j a v a2 s. c o m*/ var x = document.getElementById("myFrame").width; document.getElementById("demo").innerHTML = x; } </script> </body> </html>