I've now changed it slightly ---
scroll_to_top.html
HTML Code:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="scroll_to_top.js"></script>
<script type="text/javascript">
$(window).load(function(){
$('body').fldr_scroll_to_top({
image : "jump_to_top.png",
image_height : "5%",
image_width : "3%",
scroll_distance : 200, //Distance in pixels you have to scroll down the page before the button appears
scroll_speed : 600, //Milliseconds
fade_speed : 200, //Milliseconds
position : 3
});
});
</script>
<style type="text/css">
body {
background-image:url('http://www.freeimageslive.com/galleries/sports/music/pics/spectrum_analyser.jpg');
background-size:50% 50%;
}
</style>
</head>
<body>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
</body>
</html>
scroll_to_top.js
Code:
$.fn.fldr_scroll_to_top = function() {
var args = arguments[0] || {};
$('body').append('<image src="' + args.image + '" alt="Scroll to top" title="Scroll to top" id="scroll_to_top"/>');
switch(args.position) {
case 1:
$('#scroll_to_top').css({'top' : '0', 'left' : '0'});
break;
case 2:
$('#scroll_to_top').css({'top' : '0', 'right' : '0'});
break;
case 3:
$('#scroll_to_top').css({'bottom' : '0', 'left' : '0'});
break;
case 4:
$('#scroll_to_top').css({'bottom' : '0', 'right' : '0'});
break;
default:
$('#scroll_to_top').css({'bottom' : '0', 'left' : '0'});
}
$('#scroll_to_top').css({'margin-bottom' : '5px', 'margin-top' : '5px', 'margin-left' : '5px', 'margin-right' : '5px', 'display' : 'none', 'position': 'fixed', 'height' : args.image_height, 'width' : args.image_width, 'cursor' : 'pointer'});
$(window).scroll(function() {
if ($(this).scrollTop() > args.scroll_distance) {
$('#scroll_to_top').fadeIn(args.fade_speed);
} else {
$('#scroll_to_top').fadeOut(args.fade_speed);
}
});
$('#scroll_to_top').click(function() {
$('body,html').animate({
scrollTop: 0
}, args.scroll_speed);
});
};
Bookmarks