Frame parsing

The WebTV Viewer crashes on this script.

This script does not work in Explorer 3, Opera 3.60 and QNX Voyager.

Hotjava 3 does give output, but no <UL>.

In Netscape 3 the script works, but on exiting it gives an error.

This script prints out a frame structure for you. It can come in very useful when you inherit a site with a hideously complex frame structure.

The only thing you need to do is copy-paste the script below into a page that shows up in the frameset. It will automatically print out the names of the frames and their position in the tree.

<UL>top contains<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
var currentFrame = 'top'
var x;
var y = new Array();
y[0] = 0;
var level = 0;

function parsetree()
{
	for (i=y[level];i<x.length;i++)
	{
		document.write('<LI>The frame named ' + x.frames[i].name);
		document.write(' (containing ' + x.frames[i].document.title + ')');
		if (x.frames[i].length > 0)
		{
			currentFrame = currentFrame + '.frames[' + i + ']';
			y[level] = i + 1;
			document.write(', which contains<UL>');
			level++;
			y[level] = 0;
			return;
		}
	}
	currentFrame = currentFrame.substring(0,currentFrame.lastIndexOf('.'));
	document.write('</UL>');
	if (level == 0) currentFrame =='';
	level--;
}

while (currentFrame != '')
{
	x = eval(currentFrame);
	parsetree();
}
// -->
</SCRIPT></UL>

The script runs below (the frameset of this site is not very complicated):