防止空连接#返回到页面顶端


如果你的网页中有<a href=http://www.blue1000.com/article/“#”> .......</a> 这样的连接,而且已经出现的滚动条,并且下拉了一些,那么当点击这个连接的时候就会返回页面顶部,很是讨厌。以下几中方法可以防止这个问题:

1.将<a href=http://www.blue1000.com/article/“#”>.......</a>改为<a href=“JavaScript:;”> .......</a>

2.将<a href=http://www.blue1000.com/article/“#”> .......</a>改为<a href=http://www.blue1000.com/article/“#”onclick="return false"> .......</a>

3.如果实在不需要一个连接,而只是想让浏览者把鼠标放在这里的时候让鼠标变成手,那么你也可以将........前的<a> 去掉,用<span style="cursor:hand">代替也可以

4.将<a href=http://www.blue1000.com/article/“#”> .......</a>改为<a href=http://www.blue1000.com/article/“####”>.......</a>

5.将<a href=http://www.blue1000.com/article/=“#”> .......</a>改为<a href="JavaScript:void(0)">.....</a>

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3