I have this chunk of code that shows a "scroll to bottom" link when the page has scroll bars, or in other words when the browser height exceeds the users desktop resolution. Anyhow it works just fine if the browser window height is larger when the page initially loads but not if I resize the window after the page loads, then it wont trigger.
Any help would be appreciated.
$(function() {
// Check to see if window has scrollbars
if ($(document).height() > $(window).height()) {
$('.scrollToBottom').animate({
opacity : 'show',
height : 'show'
}, 'fast');
} else {
$('.scrollToBottom').animate({
opacity : 'hide',
height : 'hide'
}, 'fast');
}
// Click event to scroll to bottom
$('.scrollToBottom').click(function() {
$('html, body').animate({
scrollTop : $(document).height()-$(window).height()
}, 1500, 'easeOutQuint');
return false;
});
});