MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
m (Add boilerplate) |
(MediaWiki doesn't seem to realize that arrow functions exist) |
||
Line 2: | Line 2: | ||
// 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 | ||
$(function () { | $(function () { | ||
function setLinkTarget(link) { | |||
link.setAttribute("target", "_blank"); | |||
} | |||
if (window.location != window.parent.location) { | if (window.location != window.parent.location) { | ||
document.querySelectorAll("a.external").forEach( | 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); } }());