# Back to top Button

**URL:** <https://discuss.write.as/t/back-to-top-button/85>\
**Category:** Customization\
**Tags:** writeas\
**Created:** [September 14, 2018, 10:51am UTC](https://discuss.write.as/t/back-to-top-button/85 "2018-09-14T10:51:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![koulaxizis](https://discuss.write.as/user_avatar/discuss.write.as/koulaxizis/32/492_2.png) [@koulaxizis](https://discuss.write.as/u/koulaxizis)\
**Post date:** [September 14, 2018, 10:51am UTC](https://discuss.write.as/t/back-to-top-button/85/1 "2018-09-14T10:51:23Z")

</div>

Hello! 🙂

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

I think it would be handy… 😉

---

<div class="post-metadata">

**Author:** ![matt](https://discuss.write.as/user_avatar/discuss.write.as/matt/32/2760_2.png) [@matt](https://discuss.write.as/u/matt)\
**Post date:** [September 20, 2018, 9:56am UTC](https://discuss.write.as/t/back-to-top-button/85/2 "2018-09-20T09:56:10Z")

</div>

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

```auto
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);
}

```

---

<div class="post-metadata">

**Author:** ![koulaxizis](https://discuss.write.as/user_avatar/discuss.write.as/koulaxizis/32/492_2.png) [@koulaxizis](https://discuss.write.as/u/koulaxizis)\
**Post date:** [September 20, 2018, 11:13am UTC](https://discuss.write.as/t/back-to-top-button/85/3 "2018-09-20T11:13:34Z")

</div>

Nice, that worked! 🙂  
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.

---

<div class="post-metadata">

**Author:** ![matt](https://discuss.write.as/user_avatar/discuss.write.as/matt/32/2760_2.png) [@matt](https://discuss.write.as/u/matt)\
**Post date:** [September 21, 2018, 12:22am UTC](https://discuss.write.as/t/back-to-top-button/85/4 "2018-09-21T00:22:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![koulaxizis](https://discuss.write.as/user_avatar/discuss.write.as/koulaxizis/32/492_2.png) [@koulaxizis](https://discuss.write.as/u/koulaxizis)\
**Post date:** [September 24, 2018, 7:47pm UTC](https://discuss.write.as/t/back-to-top-button/85/5 "2018-09-24T19:47:59Z")

</div>

Sure! The code I want to use it this one - nothing weird, I just translated the “Back to top” text.

```
var topP = document.createElement("p");
topP.style.textAlign = "center";
topP.innerHTML = '<a href="#">Επιστροφή στην κορυφή</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);
}
```

---

<div class="post-metadata">

**Author:** ![matt](https://discuss.write.as/user_avatar/discuss.write.as/matt/32/2760_2.png) [@matt](https://discuss.write.as/u/matt)\
**Post date:** [September 24, 2018, 8:27pm UTC](https://discuss.write.as/t/back-to-top-button/85/6 "2018-09-24T20:27:56Z")

</div>

Ah, yep, looks like it was an issue with how we were storing Javascript in the database. This is fixed – if you re-save the JS just like that it should work now 🙂

---

<div class="post-metadata">

**Author:** ![koulaxizis](https://discuss.write.as/user_avatar/discuss.write.as/koulaxizis/32/492_2.png) [@koulaxizis](https://discuss.write.as/u/koulaxizis)\
**Post date:** [September 28, 2018, 6:57am UTC](https://discuss.write.as/t/back-to-top-button/85/7 "2018-09-28T06:57:57Z")

</div>

It worked fine, thanks a lot! 🙂

---

<div class="post-metadata">

**Author:** ![Aris](https://discuss.write.as/user_avatar/discuss.write.as/aris/32/58_2.png) [@Aris](https://discuss.write.as/u/Aris)\
**Post date:** [February 12, 2019, 6:40pm UTC](https://discuss.write.as/t/back-to-top-button/85/8 "2019-02-12T18:40:27Z")

</div>

@matt the result is centred on home and tag page, but not in blog post page.
