「MediaWiki:Gadget-exlinks.js」の版間の差分

update; copy from enwiki w:Special:PermaLink/609653720
(w:MediaWiki:Gadget-exlinks.js 2008年2月25日 (月) 14:57 の版より作成)
 
(update; copy from enwiki w:Special:PermaLink/609653720)
// ** **
// **********************************************************************
/**
addOnloadHook(function() {
* @source mediawiki.org/wiki/Snippets/Open_external_links_in_new_window
var content = document.getElementById('content');
* @version 5
if(!content) content = document.getElementById('mw_content');
*/
if(!content) return;
mw.hook('wikipage.content').add(function($content) {
var alinks = content.getElementsByTagName('a');
// Second selector is for external links in Parsoid HTML+RDFa output (bug 65243).
var tablink, sitename;
$content.find('a.external, a[rel="mw:ExtLink"]').each(function () {
for (var i = 0, leng = alinks.length; i < leng; i++) {
// Can't use wgServer because it can be protocol relative
tablink = alinks[i];
// Use this.href property instead of this.getAttribute('href') because the property
if (tablink.className.indexOf("external") != -1 && tablink.href.indexOf(wgServer) != 0)
// is converted to a full URL (including protocol)
tablink.target = "_blank";
if (this.href.indexOf(location.protocol + '//' + location.hostname) !== 0) {
}
tablink this.target = "'_blank"';
}
});
});
752

回編集