MediaWiki:Common.js

From softwear.directory
Revision as of 07:50, 22 December 2023 by Admin (talk | contribs) (Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: // Get the modal var modal1 = document.getElementById("aboutModal"); // Get the button that opens the modal var btn1 = document.getElementById("aboutBtn"); // Get the <span> element that closes the modal var span1 = document.getElementsByClassName("close1")[0]; // When the user clicks the button, open the modal btn1.onclick = function() { modal1.style.display = "block"; } // When the user click...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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. */
// Get the modal
var modal1 = document.getElementById("aboutModal");
// Get the button that opens the modal
var btn1 = document.getElementById("aboutBtn");
// Get the <span> element that closes the modal
var span1 = document.getElementsByClassName("close1")[0];
// When the user clicks the button, open the modal 
btn1.onclick = function() {
  modal1.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span1.onclick = function() {
  modal1.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
  if (event.target == modal1) {
    modal1.style.display = "none";
  }
}