html 锚点的使用

使用js与<a>两种方式

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> <title>锚点</title> </head> <mce:script type="text/javascript"><!-- function go(){ window.location.hash="m2" return false; } // --></mce:script> <body> <a href="#" mce_href="#" onclick="return go()" >跳到2</a> <a href="#m3" mce_href="#m3">跳到3</a> <a href="test.html#m3" mce_href="test.html#m3">跳到test.html#m3</a> <p>start...<p> <div style="margin-top:500px" mce_style="margin-top:500px"> <p id="m2">hello m2!</p> helloWorld! </div> <div style="margin-top:500px" mce_style="margin-top:500px"> <p><a name="m3"></a>hello m3</p> </div> <div style="padding-top:1000px" mce_style="padding-top:1000px"></div> </body> </html>

test.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> <title>锚点</title> </head> <body> <p>11111111<p> <div style="margin-top:500px" mce_style="margin-top:500px"> <p id="m2">helloWorld!</p> helloWorld! </div> <div style="margin-top:500px" mce_style="margin-top:500px"> <p><a name="m3"></a>test.html:helloWorld!</p> </div> <div style="padding-top:1000px" mce_style="padding-top:1000px"></div> </body> </html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值