当前位置: 代码迷 >> JavaScript >> [JavaScript][页面定位]锚的容易使用
  详细解决方案

[JavaScript][页面定位]锚的容易使用

热度:156   发布时间:2013-03-25 15:43:04.0
[JavaScript][页面定位]锚的简单使用

源:http://blog.csdn.net/szwangdf/article/details/4205553

评:

?[页面定位]锚的简单使用

?

1.使用window.location.hash定位到指定的锚

?

[xhtml] view plaincopy
  1. <!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.0?Transitional//EN">??
  2. <HTML>??
  3. <HEAD>??
  4. <TITLE>?New?Document?</TITLE>??
  5. <META?NAME="Generator"?CONTENT="EditPlus">??
  6. <META?NAME="Author"?CONTENT="">??
  7. <META?NAME="Keywords"?CONTENT="">??
  8. <META?NAME="Description"?CONTENT="">??
  9. ??
  10. <mce:script?laguage="javascript"><!--??
  11. ????function?onTopClick()?{??
  12. ????????window.location.hash?=?"#top";???
  13. ????}??
  14. ????function?onBottomClick()?{??
  15. ????????window.location.hash?=?"#bottom";???
  16. ????}??
  17. //?--></mce:script>???
  18. </HEAD>??
  19. ??
  20. <BODY>??
  21. ????<a?name="top"></a>??
  22. ????<input?id="btnBottom"?type="button"?onclick="javascript:onBottomClick()"?value="跳转到底部"/><BR>??
  23. ????????1<BR>2<BR>3<BR>4<BR>5<BR>??
  24. ????????1<BR>2<BR>3<BR>4<BR>5<BR>??
  25. ????????1<BR>2<BR>3<BR>4<BR>5<BR>??
  26. ????????1<BR>2<BR>3<BR>4<BR>5<BR>??
  27. ????????1<BR>2<BR>3<BR>4<BR>5<BR>??
  28. ????????1<BR>2<BR>3<BR>4<BR>5<BR>??
  29. ????????1<BR>2<BR>3<BR>4<BR>5<BR>??
  30. ????????1<BR>2<BR>3<BR>4<BR>5<BR>??
  31. ????????1<BR>2<BR>3<BR>4<BR>5<BR>??
  32. ????????1<BR>2<BR>3<BR>4<BR>5<BR>??
  33. ????????1<BR>2<BR>3<BR>4<BR>5<BR>??
  34. ????????1<BR>2<BR>3<BR>4<BR>5<BR>??
  35. ????<input?id="btnBottom"?type="button"?onclick="javascript:onTopClick()"?value="跳转到顶部"/><BR>??
  36. ????<a?name="bottom"></a>??
  37. </BODY>??
  38. </HTML>?
  相关解决方案