Suggestions

"Scroll to top" Button

Submitted by _soxx, , Thread ID: 119126

Thread Closed

RE: "Scroll to top" Button

This post was last modified: 30-01-2019, 06:56 AM by kadreyalta
#9
There is an anchor tag in the source of the site which suggests that this was an intended feature in the past.

[Image: CmbnFDR.png]


The only issue is that the href value is what keeps this from working as intended since my tests with Javascript always results in redirecting to the homepage when clicked.

So my way of doing this was by using the following Javascript/ECMAScript code:
Code:
function totop() {
document.body.scrollTop = document.documentElement.scrollTop = 0;
}

let foot = document.getElementsByClassName('spacer-left-5 spacer-right-5')[0],
adiv = document.createElement('div'),
link = document.createElement('a');

adiv.setAttribute('class', 'footer-link');
link.setAttribute('href', 'javascript:totop()');
link.innerHTML = 'Goto top of page';
adiv.appendChild(link);
foot.appendChild(adiv);
With some extra touches (mainly CSS) this could wind up looking like it was a part of the site (this works best as a greasemonkey/tampermonkey script).
1

Users browsing this thread: 6 Guest(s)