Posted By

LukeLux on 09/24/10


Tagged

scroll textmate jquery scrolling


Versions (?)

Scrolling Windows Browser


 / Published in: Other
 

  1. $(function(){
  2. $('a[href="#footer"]').click(function() { //href linking to # (has to be hash)
  3. if (location.pathname.replace(/^//,'') == this.pathname.replace(/^//,'')
  4. && location.hostname == this.hostname) {
  5. var $target = $(this.hash);
  6. $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
  7. if ($target.length) {
  8. var targetOffset = $target.offset().top;
  9. $('html,body').animate({scrollTop: targetOffset}, 1000);
  10. return false;
  11. }
  12. }
  13. });
  14. $('a[href="#header"]').click(function() {
  15. if (location.pathname.replace(/^//,'') == this.pathname.replace(/^//,'')
  16. && location.hostname == this.hostname) {
  17. var $target = $(this.hash);
  18. $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
  19. if ($target.length) {
  20. var targetOffset = $target.offset().top;
  21. $('html,body').animate({scrollTop: targetOffset}, 1000);
  22. return false;
  23. }
  24. }
  25. });
  26. });

Report this snippet  

You need to login to post a comment.