Hi everyone,
I'm using two scripts that are conflicting with each other. You ask
why I'm using wo scripts?
One script is used for scrolling to the top of a long page from a
bottom link.
The other script is used for smooth scrolling to local anchors.
I'm using a ajax to load external html within DIV's.
It's funny how they work. The script placed in first order works
making the other script next in line not to work.
Here are my two scripts:
SCRIPT ONE:
function scrollWin(){
$('html, body').animate({
scrollTop: $("#top").offset().top
}, 3000);
}
SCRIPT TWO:
(function($){
$.extend({
smoothAnchors : function(speed, easing, redirect){
speed = speed || "slow";
easing = easing || null;
redirect = (redirect === true || redirect == null) ?
true : false;
$("a").each(function(i){
var url = $(this).attr("href");
if(url){
if(url.indexOf("#") != -1 &&
url.indexOf("#") == 0){
var aParts = url.split("#",2);
var anchor =
$("a[name='"+aParts[1]+"']");
if(anchor){
$(this).click(function(){
if($(document).height()-anchor.offset().top >= $(window).height
()
||
anchor.offset().top > $(window).height()
|| $(document).width()-anchor.offset().left >= $(window).width
()
||
anchor.offset().left > $(window).width()){
$('html, body').animate({
scrollTop: anchor.offset().top,
scrollLeft: anchor.offset().left
},
speed, easing, function(){
if(redirect){
window.location = url
}
});
}
return false;
});
}
}
}
});
}
});
})(jQuery);
Any help would be greatly appreciated.
Many thanks.
Erik