最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Top of Page Javascript Bookmarklet - Stack Overflow

programmeradmin0浏览0评论

Can anyone tell me how to turn

<a href="javascript:scroll(0,0)"> Top</a>

aka the Top of Page link into a Bookmarklet.

Not very knowledgeable with JavaScript and cannot get this into want I want it to be.

Or if I am using the wrong code, then can you fix it for me and turn it into the bookmarklet.

Can anyone tell me how to turn

<a href="javascript:scroll(0,0)"> Top</a>

aka the Top of Page link into a Bookmarklet.

Not very knowledgeable with JavaScript and cannot get this into want I want it to be.

Or if I am using the wrong code, then can you fix it for me and turn it into the bookmarklet.

Share Improve this question edited Jun 1, 2009 at 16:14 GEOCHET 21.3k15 gold badges77 silver badges99 bronze badges asked May 27, 2009 at 13:22 ethanethan
Add a ment  | 

3 Answers 3

Reset to default 8

Create a bookmark with location:

javascript:void(function(){window.scroll(0,0)}())

Works in Firefox 3 and IE 7.

Another option ...

function scrollUp(){
  var offy;
  if(self.pageYOffset) {
        offy = self.pageYOffset;
  } else if(document.documentElement && document.documentElement.scrollTop){
        offy = document.documentElement.scrollTop;
  } else {
        offy = document.body.scrollTop;
  }

  if(offy <= 0) return;

  window.scrollBy(0, -50);
  setTimeout("scrollUp()", 10);

}

<a href="javascript: scrollUp();">Start Scroller!</a>

here is an article from my bookmarks .. its a simple and easy solution that I have been using for a long time now.

http://www.geeksww./tutorials/web_development/javascript/tips_and_tricks/javascript_go_to_top_of_page.php

hope this works

发布评论

评论列表(0)

  1. 暂无评论