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 phrame = '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 + ' (containing ' + x.frames[i].document.title + ')');
    		if (x.frames[i].length > 0)
    		{
    			phrame = phrame + '.frames[' + i + ']';
    			y[level] = i + 1;
    			document.write(', which contains<UL>');
    			level++;
    			y[level] = 0;
    			return;
    		}
    	}
    	phrame = phrame.substring(0,phrame.lastIndexOf('.'));
    	document.write('</UL>');
    	if (level == 0) phrame =='';
    	level--;
    }
    
    while (phrame != '')
    {
    	x = eval(phrame);
    	parsetree();
    }
    // -->
    </SCRIPT></UL>
    

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

    To see this script at work in a more complicated frameset, see the copy used in the Introduction to frames.

    Home