Back to top Button

writeas

#1

Hello! :slight_smile:

Is there any way to add a “back-to-top” button or text to the blog?

I think it would be handy… :wink:


#2

Hey, you can do that today with a bit of Javascript:

var topP = document.createElement("p");
topP.style.textAlign = "center";
topP.innerHTML = '<a href="#">Back to top</a>';
var cont = document.getElementById("wrapper");
if (cont !== null) {
    // Add to blog index and tag pages
    cont.appendChild(topP);
} else {
    // Add to individual blog post page
    cont = document.getElementById("post-body");
    cont.insertAdjacentHTML("afterend", topP.outerHTML);
}

#3

Nice, that worked! :slight_smile:
Is there a way to add utf-8 encoding to replace the text with Greek translation?
I tried to do it and I only got question mark symbols.


#4

Awesome!

I might have to make some changes on our end to get Greek text working. Could you send me an example URL or the exact JS you’re using (either privately, or on this thread)? Then I can make the changes and verify that they work.