MediaWiki:Common.js

From Disaster Risk Gateway
Revision as of 18:01, 25 March 2025 by Myriad-admin (talk | contribs)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
$(document).ready(function() {
    // Check if we are NOT on the main page
    if (mw.config.get('wgPageName') !== mw.config.get('wgMainPageTitle').replace(/ /g, '_')) {
        // Create the back button
        var backButton = $('<button id="backButton">Go Back</button>');
        
        // Apply styles
        backButton.css({
            "position": "fixed",
            "bottom": "20px",
            "left": "20px",
            "background-color": "#007bff",
            "color": "white",
            "border": "none",
            "padding": "5px 10px",
            "font-size": "14px",
            "cursor": "pointer",
            "border-radius": "5px",
            "box-shadow": "0px 2px 5px rgba(0,0,0,0.2)"
        });

        // Add click function to go back
        backButton.click(function() {
            history.back();
        });

        // Add the button to the page
        $("body").append(backButton);
    }
});