The length
property returns the number of frames including iframes in the current window.
length |
Yes | Yes | Yes | Yes | Yes |
window.length
The number of frames (including iframes) in the current window.
The following code shows how to Find the number of frames on a page.
<!DOCTYPE html>
<html>
<body>
<!-- ww w.j a v a 2s . c o m-->
<iframe src="http://www.cnn.com"></iframe>
<iframe src="http://www.bbc.com"></iframe>
<iframe src="http://www.example.com"></iframe>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = window.length;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: