Use window.frames["frameName"].length in JavaScript

Description

The following code shows how to use window.frames["frameName"].length to access the number of frame instances in a document.

Example


<html>
<script language="JavaScript">
for(var i = 0; i <= window.frames.length; i++){
newWin.document.write("The name of frame #" + i);
newWin.document.write(" is " + window.frames[i].name + "<br>");
}<!--from  w w  w.  j av  a2 s .  c  om-->
</script>
</html>

Click to view the demo

The code above generates the following result.

Use window.frames["frameName"].length in JavaScript