sample25页面源代码:
<html>
<head>
<title>框架页</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
</head>
<frameset cols="30%,*">
<frame src="sample25_left.htm" name="left">
<frame src="sample25_right.htm" name="right">
</frameset>
</html>
sample25_left页面源代码:
<html>
<head>
<title>目录</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
</head>
<body>
</body>
</html>
sample25_right页面源代码:
<html>
<head>
<title>内容</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<script type="text/javascript" language="javascript">
<!--
//通过循环创建超链接
for (i=1;i<10;i++)
{
//设置超链接和锚
document.write("<a href='#' name='a",i,"'>第",i,"章</a><br>");
//通过循环添加一些行,可以方便查看效果
for (j=1;j<20;j++)
{
document.write(" 第",j,"节<br>");
}
}
//获得左边框的Window对象
var leftWin = window.parent.left;
leftWin.document.open();
//添加目录
leftWin.document.write("<p align='center'>目录</p>");
//根据当前文档中的所有锚对象来创建目录
for (i=0;i<document.anchors.length;i++)
{
leftWin.document.write("<a href='sample25_right.htm#",document.anchors[i].name,"' target='right'>第",i+1,"章</a><br>");
}
leftWin.document.close();
-->
</script>
</head>
<body>
</body>
</html>
<html>
<head>
<title>框架页</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
</head>
<frameset cols="30%,*">
<frame src="sample25_left.htm" name="left">
<frame src="sample25_right.htm" name="right">
</frameset>
</html>
sample25_left页面源代码:
<html>
<head>
<title>目录</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
</head>
<body>
</body>
</html>
sample25_right页面源代码:
<html>
<head>
<title>内容</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<script type="text/javascript" language="javascript">
<!--
//通过循环创建超链接
for (i=1;i<10;i++)
{
//设置超链接和锚
document.write("<a href='#' name='a",i,"'>第",i,"章</a><br>");
//通过循环添加一些行,可以方便查看效果
for (j=1;j<20;j++)
{
document.write(" 第",j,"节<br>");
}
}
//获得左边框的Window对象
var leftWin = window.parent.left;
leftWin.document.open();
//添加目录
leftWin.document.write("<p align='center'>目录</p>");
//根据当前文档中的所有锚对象来创建目录
for (i=0;i<document.anchors.length;i++)
{
leftWin.document.write("<a href='sample25_right.htm#",document.anchors[i].name,"' target='right'>第",i+1,"章</a><br>");
}
leftWin.document.close();
-->
</script>
</head>
<body>
</body>
</html>