Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- How to prevent button on the page loading?


Fotiman - 2:11 pm on Jan 25, 2013 (gmt 0)


You're attaching an event listener to the window's scroll event. When the page first loads, that event won't be fired, so you need to also repeat that functionality in the ready method.

jQuery(document).ready(function () {

if (jQuery(window).scrollTop() != 0) {
jQuery('.mybutton1').fadeIn();
} else {
jQuery('.mybutton1').fadeOut();
}

jQuery(window).scroll(function () {
if (jQuery(this).scrollTop() != 0) {
jQuery('.mybutton1').fadeIn();
} else {
jQuery('.mybutton1').fadeOut();
}
});

jQuery('.mybutton1').click(function () {
jQuery("html, body").animate({
scrollTop: 0
}, 850);
return false;
});

});


Thread source:: http://www.webmasterworld.com/javascript/4539236.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com