MediaWiki:Common.js: Difference between revisions

From lotico
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:


$(document).ready(function() {
$(document).ready(function() {
     $('span.popup-link a').once('popup-link').on('click', function(e) {
    // Detect all links generated by the template
        e.preventDefault(); // Stop default navigation
     $('a').once('popup-link').each(function() {
        window.open(
        var href = $(this).attr('href');
            this.href,
 
            'popupWindow',
        // Example: only open popups for external links
            'width=600,height=400,scrollbars=yes,resizable=yes'
        if (href && href.startsWith('http')) {
        );
            $(this).on('click', function(e) {
                e.preventDefault(); // Stop default navigation
                window.open(this.href, 'popupWindow', 'width=600,height=400,scrollbars=yes,resizable=yes');
            });
        }
     });
     });
});
});

Revision as of 20:41, 6 September 2025

/* Any JavaScript here will be loaded for all users on every page load. */

$(document).ready(function() {
    // Detect all links generated by the template
    $('a').once('popup-link').each(function() {
        var href = $(this).attr('href');

        // Example: only open popups for external links
        if (href && href.startsWith('http')) {
            $(this).on('click', function(e) {
                e.preventDefault(); // Stop default navigation
                window.open(this.href, 'popupWindow', 'width=600,height=400,scrollbars=yes,resizable=yes');
            });
        }
    });
});