码迷,mamicode.com
首页 > 编程语言 > 详细

JavaScript code to let users double-click to move back to the top of the page

时间:2015-06-18 21:33:16      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:

 

Here‘s some JavaScript code I found today while poking around the net. Embed this JavaScript code in a web page, and a user can simply double-click anywhere on the page to automatically move back to the beginning of the page. Pretty cool idea. Here‘s the code:

<script language="JavaScript1.2" 
           type="text/javascript">
<!--
function dblclick() 
{ 
  window.scrollTo(0,0) 
}
if (document.layers) 
{ 
  document.captureEvents(ONDBLCLICK); 
}
document.ondblclick=dblclick; 
-->
</script>

  

JavaScript code to let users double-click to move back to the top of the page

标签:

原文地址:http://www.cnblogs.com/hephec/p/4586819.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!