Anchor锚对象--目录

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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值