< Snippets
![]() | |
---|---|
Language(s): | JavaScript |
Compatible with: | MediaWiki 1.22+ (Vector; Monobook; Modern) |
This snippet allows any given link that's directly wrapped inside an element with class="newwin" to open on a new window when clicked.
For example, this syntax would make the link to open on a new window when clicked:
<span class="newwin">[[MediaWiki]]</span>
Code
/**
* @source https://www.mediawiki.org/wiki/Snippets/Open_specific_links_in_new_window
* @version 2018-09-15
*/
$( function () {
$( '#mw-content-text' ).on( 'click', '.newwin > a', function () {
var otherWindow = window.open();
otherWindow.opener = null;
otherWindow.location = this;
return false;
} );
} );
See also
This article is issued from Mediawiki. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.