Thanks for the reply.
I know nothing about Javascript.
I spend a long time looking for answers and try to use from there,as you will see from my efforts below of which as we know didnt work.
Code:
<img src="misc/BACK-TO-TOP.png" alt="The Attic Banwell Shabby Chic Items" width="150" height="50" onclick="myfunction()" >
Code:
<script>
HTMLElement.prototype.scrollTo = function(to, duration, ori = 'h', callback = function() {}) {
var start = (ori == 'h' ? this.scrollLeft : this.scrollTop),
change = to - start,
currentTime = 0,
increment = 20,
element = this;
var animateScroll = function() {
currentTime += increment;
var val = Math.easeInOutQuad(currentTime, start, change, duration);
if ( ori == 'h' )
element.scrollLeft = val;
else
element.scrollTop = val;
if(currentTime < duration) {
setTimeout(animateScroll, increment);
} else {
callback();
}
};
animateScroll();
}; // end scrollTo
Math.easeInOutQuad = function (t, b, c, d) {
t /= d/2;
if (t < 1) return c/2*t*t + b;
t--;
return -c/2 * (t*(t-2) - 1) + b;
};
document.addEventListener("click", function(){
document.getElementById('main').scrollTo(0, 500, 'v');
</script>
</body>
<div id="footer">
</div>
</script>
Bookmarks