Find out how many <iframe> elements there are in the window:
var x = window.length;
Click the button to get the number of frames found on this page.
<!DOCTYPE html> <html> <body> <iframe src="https://www.cnn.com"></iframe> <iframe src="https://www.bbc.com"></iframe> <iframe src="https://www.nytimes.com"></iframe> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w .j av a 2s . c om*/ var x = window.length; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The length property returns the number of <iframe> elements in the current window.
This property is often used together with the window.frames property.
This property is read-only.