MediaWiki:Common.js

From Fungal Genomics

(Difference between revisions)
Jump to: navigation, search
(Created page with '/* 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.: onload=function(){ if (do…')
Line 18: Line 18:
       }
       }
     }
     }
-
     makeExt('external');
+
     makeNewWindow('external');
-
     function makeExt(lclass) {
+
     function makeNewWindow(lclass) {
       links = document.getElementsByClassName(lclass);
       links = document.getElementsByClassName(lclass);
       // add onClick handler to links
       // add onClick handler to links
       for (var i = 0; (element = links[i]) != null; i++) {
       for (var i = 0; (element = links[i]) != null; i++) {
-
         element.href = "/frame/?l="+escape(element.href);
+
         element.onclick="window.open("+element.href+")";
       }
       }
     }
     }
}
}

Revision as of 18:50, 1 April 2011

/* 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. */

onload=function(){
  if (document.getElementsByClassName == undefined) {
    document.getElementsByClassName = function(className) {
      var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)");
        var allElements = document.getElementsByTagName("*");
        var results = [];

        var element;
        for (var i = 0; (element = allElements[i]) != null; i++) {
          var elementClass = element.className;
          if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass))
            results.push(element);
          }
        return results;
      }
    }
    makeNewWindow('external');
    function makeNewWindow(lclass) {
      links = document.getElementsByClassName(lclass);
      // add onClick handler to links
      for (var i = 0; (element = links[i]) != null; i++) {
        element.onclick="window.open("+element.href+")";
      }
    }
}
Personal tools