MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
Bjarni Bemar (talk | contribs) Created page with "→Any JavaScript here will be loaded for all users on every page load.: // Breyta &printable=yes í &action=render í öllum hlekkjum á síðunni mw.hook('wikipage.content').add(function ($content) { $content.find('a[href*="printable=yes"]').each(function () { var $link = $(this); var href = $link.attr('href'); // Skipta út printable=yes fyrir action=render var newHref = href.replace('printable=yes', 'action=render');..." |
Bjarni Bemar (talk | contribs) No edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
/ | // Hluti 1: Grípa smellinn dýnamískt | ||
$(document).ready(function() { | |||
$('body').on('click', 'a', function(e) { | |||
$ | var href = $(this).attr('href'); | ||
var | if (href && href.indexOf('printable=yes') !== -1) { | ||
e.preventDefault(); | |||
var newHref = href.replace('printable=yes', 'action=render'); | |||
window.location.href = newHref; | |||
} | |||
}); | }); | ||
}); | }); | ||
// Hluti 2: Ef notandinn lendir samt á printable síðu, áframsenda strax | |||
if (window.location.href.indexOf('printable=yes') !== -1) { | |||
window.location.href = window.location.href.replace('printable=yes', 'action=render'); | |||
} | |||
Latest revision as of 06:07, 20 October 2026
// Hluti 1: Grípa smellinn dýnamískt
$(document).ready(function() {
$('body').on('click', 'a', function(e) {
var href = $(this).attr('href');
if (href && href.indexOf('printable=yes') !== -1) {
e.preventDefault();
var newHref = href.replace('printable=yes', 'action=render');
window.location.href = newHref;
}
});
});
// Hluti 2: Ef notandinn lendir samt á printable síðu, áframsenda strax
if (window.location.href.indexOf('printable=yes') !== -1) {
window.location.href = window.location.href.replace('printable=yes', 'action=render');
}