Difference between revisions of "MediaWiki:LastPage.js"

From Tycoon Gaming
(Created page with "var path = window.location.href; var path1 = 'https://dash.tycoon.community/wiki/index.php/User:Donald' function iniFrame() { if ( window.location !== window.parent.location...")
 
m (hehh)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
var path = window.location.href;
+
// Define a function called addLastPageButton
var path1 = 'https://dash.tycoon.community/wiki/index.php/User:Donald'
+
function addLastPageButton() {  
function iniFrame() {  
+
  // Check if the current page is loaded inside an iframe
if ( window.location !== window.parent.location )  
+
  if (window.location !== window.parent.location) {
{
+
    // If so, create a new variable called 'output'
var output;
+
    var output;
window.element = document.getElementById("globalWrapper");
+
    // Create a new div element to contain the button
var save = window.element.innerHTML;
+
    var container = document.createElement("div");
output = '<button class="LastPage" onclick="var oldURL = document.referrer; window.location.href = oldURL;">Return to Last Page</button>'
+
    // Set the innerHTML of the container to the button code
window.element.innerHTML = save + output;
+
    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);
 +
  }
 
}
 
}
iniFrame();
+
 
 +
// Call the addLastPageButton function when the page loads
 +
addLastPageButton();

Latest revision as of 20:48, 29 April 2023

// Define a function called addLastPageButton
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();