What am I missing here? I have a back to top link script working in Firefox which no longer works in Chrome or Safari wondering if anyone notices anything here? I have added alert messages through the script to test and make sure the entire script is running and am able to get prompts at every point. It seems like the clicking of the #back-to-top object just doesn’t scroll to top in chrome and safari.
JavaScript:
HTML:
CSS:
JavaScript:
JavaScript:
jQuery(window).load(function () {
initTopLink('#back-to-top', 400, 300);
});
// back to top scrolling
function initTopLink(element, min, fadeSpeed) {
var el = $(element);
if ($(window).height() >= min) {
// Scroll Top Link
$(element).click(function (e) {
e.preventDefault();
$.scrollTo(0, 300);
return false;
});
//listen for scroll
el.hide(); //in case the user forgot
$(window).scroll(function () {
if ($(window).scrollTop() == "0") {
el.fadeOut(fadeSpeed);
} else {
el.fadeIn(fadeSpeed);
}
});
}
}
HTML:
HTML:
<div id="back-to-top" ><a href="#top"><span>Back to top</span></a></div>
CSS:
CSS:
#back-to-top span { display: none; }
#back-to-top {
border: none;
bottom: 0;
cursor: pointer;
display: none;
margin-bottom: 30px;
position: fixed;
right: 30px;
z-index: 50000;
height: 0;
width: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-bottom: 32px solid #e02d42;
-moz-transform: scale(.9999);
}
#back-to-top a:hover {
border: none;
}