MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
(Open external links in a new window if wiki page is being framed inside the Flashpoint Help Manual) |
(MediaWiki doesn't seem to realize that arrow functions exist) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
// If wiki page is framed (e.g. in the Flashpoint Help Menu), open external links in a new window | // If wiki page is framed (e.g. in the Flashpoint Help Menu), open external links in a new window | ||
if (window.location != window.parent.location) { | $(function () { | ||
function setLinkTarget(link) { | |||
link.setAttribute("target", "_blank"); | |||
} | |||
if (window.location != window.parent.location) { | |||
document.querySelectorAll("a.external").forEach(setLinkTarget); | |||
} | |||
}()); |
Latest revision as of 12:17, 13 August 2022
/* Any JavaScript here will be loaded for all users on every page load. */ // If wiki page is framed (e.g. in the Flashpoint Help Menu), open external links in a new window $(function () { function setLinkTarget(link) { link.setAttribute("target", "_blank"); } if (window.location != window.parent.location) { document.querySelectorAll("a.external").forEach(setLinkTarget); } }());