see if this works:
http://jsfiddle.net/uzpcV/25/
extracting the "#id"
scrolling to that location
then canceling our the original click functionality
$(document).ready(function() {
function addClick(anchor,theUrl,i){
anchor.click(function() {
var whereToGo = theUrl.substr(theLocation);
$('html, body').animate({
scrollTop: $(eval('"' + whereToGo + '"')).offset().top
}, 333);
//hold it right there
return false;
});
}
var allTheLinks = $("a");
var linksLength = allTheLinks.length;
//go through all the links
for (var i = 0; i < linksLength; i++) {
var theLink = allTheLinks.eq(i);
var theUrl = theLink.attr("href");
var theLocation = theUrl.indexOf("#");
//check for #
if (theLocation > -1) {
addClick(theLink,theUrl,i)
}
}
});