Back to top links in Mediawiki/Wikipedia


  • Administrator
  • Hero Member
  • *****
    • Posts: 835229
    • Gender:Male
  • point d’amour
Back to top links in Mediawiki/Wikipedia

Back to top and search suggestions on Project:Support desk
Wikipedia:Back to top - Wikipedia

Or, if you have Edit section disabled you can use mw-headline to trigger the event (add in Common.js):

Code: [Select]
( function () {
var elems = document.getElementsByClassName('mw-headline'); // *** NOTE: ClassName may need to be 'mw-editsection' instead
for (i = 0; i < elems.length; i++) {
var span = document.createElement('span');
var link = document.createElement('a');
link.href = '#top';
link.appendChild(document.createTextNode('back to top'));
span.appendChild(document.createTextNode('] '));
elems[i].insertBefore(span, elems[i].firstChild);

Since I also added a style, you need to add the following in Common.css to have the text in a small size and right-aligned.

Code: [Select]
span.ttop {
    float: right;
    font-size: small;


Search Tools