Difference between revisions of "MediaWiki:LastPage.js"
From Tycoon Gaming
BelgianCat (talk | contribs) m (reverting back to Donald's. Just noticed it's based on the css styling in common.css lololol no wonder it wasn't changing) |
BelgianCat (talk | contribs) m (testing alternative code (chatGPT)) |
||
Line 1: | Line 1: | ||
− | function iniFrame() { | + | // Define a function called iniFrame |
− | + | function addLastPageButton() { | |
− | + | // Check if the current page is loaded inside an iframe | |
− | + | if (window.location !== window.parent.location) { | |
− | + | // If so, create a new variable called 'output' | |
− | + | var output; | |
− | + | // Create a new div element to contain the button | |
− | + | var container = document.createElement("div"); | |
− | + | // Set the innerHTML of the container to the button code | |
+ | container.innerHTML = '<button class="LastPage" onclick="var oldURL = document.referrer; window.location.href = oldURL;"><b>Return to Last Page</b></button>'; | ||
+ | // Append the container to the body of the page | ||
+ | document.body.appendChild(container); | ||
+ | } | ||
} | } | ||
− | + | ||
+ | // Call the addLastPageButton function when the page loads | ||
+ | addLastPageButton(); |
Revision as of 20:42, 29 April 2023
// Define a function called iniFrame function addLastPageButton() { // Check if the current page is loaded inside an iframe if (window.location !== window.parent.location) { // If so, create a new variable called 'output' var output; // Create a new div element to contain the button var container = document.createElement("div"); // Set the innerHTML of the container to the button code container.innerHTML = '<button class="LastPage" onclick="var oldURL = document.referrer; window.location.href = oldURL;"><b>Return to Last Page</b></button>'; // Append the container to the body of the page document.body.appendChild(container); } } // Call the addLastPageButton function when the page loads addLastPageButton();