Difference between revisions of "MediaWiki:Common.js"

From Astrolords
Jump to: navigation, search
(Created page with "Any JavaScript here will be loaded for all users on every page load.: function ExtLinks() { var extlinks = document.getElementsByClassName('extlink'); for (var ...")
 
 
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
function ExtLinks() {  
 
function ExtLinks() {  
     var extlinks = document.getElementsByClassName('extlink');  
+
     var extlinks = document.getElementsByClassName('external');  
 
     for (var i=0, il=extlinks.length; i<il; i++) {  
 
     for (var i=0, il=extlinks.length; i<il; i++) {  
 
         var ele = extlinks[i];  
 
         var ele = extlinks[i];  
 
         var link = ele.getElementsByTagName('a')[0];  
 
         var link = ele.getElementsByTagName('a')[0];  
 
         if (link) link.setAttribute('target','_blank');
 
         if (link) link.setAttribute('target','_blank');
 +
        else ele.setAttribute('target','_blank');
 
     };  
 
     };  
 
};  
 
};  
 
addOnloadHook(ExtLinks);
 
addOnloadHook(ExtLinks);

Latest revision as of 17:52, 20 May 2014

/* Any JavaScript here will be loaded for all users on every page load. */
function ExtLinks() { 
    var extlinks = document.getElementsByClassName('external'); 
    for (var i=0, il=extlinks.length; i<il; i++) { 
         var ele = extlinks[i]; 
         var link = ele.getElementsByTagName('a')[0]; 
         if (link) link.setAttribute('target','_blank');
         else ele.setAttribute('target','_blank');
    }; 
}; 
addOnloadHook(ExtLinks);