Created
June 11, 2011 05:26
-
-
Save sirneb/1020279 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('div.toc a').bind('click', function(event) { | |
go_to_top(); | |
$.get($(this).attr("href"), $(this).serialize(), null, "script"); | |
if ( history.pushState ){ // trying to use this clause to check pushState compability | |
event.preventDefault(); | |
history.pushState(null, "", this.href); // pushes the URL to link bar | |
} | |
return false; | |
}) | |
// UI enhancement script that makes sure the user isn't too far away from the top of the page, will scroll up if so | |
function go_to_top(){ | |
// alert($('#content_title').offset().top); | |
if(window.pageYOffset > $('#content_title').offset().top){ | |
$('html, body').animate({'scrollTop':$('#content_title').offset().top}, 'fast'); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment