Difference between revisions of "User:Edward.81/vector.js"
Line 20: | Line 20: | ||
} | } | ||
+ | //create onDomReady Event | ||
+ | window.onDomReady = DomReady; | ||
+ | |||
+ | //Setup the event | ||
+ | function DomReady(fn){ | ||
+ | //W3C | ||
+ | if(document.addEventListener){ | ||
+ | document.addEventListener("DOMContentLoaded", fn, false); | ||
+ | }else{//IE | ||
+ | document.onreadystatechange = function(){readyState(fn)} | ||
+ | } | ||
+ | } | ||
+ | |||
+ | //IE execute function | ||
+ | function readyState(fn){ | ||
+ | //dom is ready for interaction | ||
+ | if(document.readyState == "interactive"){ | ||
+ | fn(); | ||
+ | } | ||
+ | } | ||
Line 25: | Line 45: | ||
//location.href.lastIndexOf("/"); | //location.href.lastIndexOf("/"); | ||
//location.href.length | //location.href.length | ||
− | + | function onReady() | |
− | var loc = location.href.substring(location.href.lastIndexOf("/")+1,location.href.length); | + | { |
− | + | var loc = location.href.substring(location.href.lastIndexOf("/")+1,location.href.length); | |
− | if (intcodes.indexOf(loc)){ | + | |
− | + | if (intcodes.indexOf(loc)){ | |
− | + | x = document.getElementById('n-mainpage-description').children[0]; | |
+ | x.href = x.href + "/" + intcodes[loc]; | ||
+ | } | ||
} | } |
Revision as of 12:30, 9 July 2011
var intcodes =["ru","fr","de","pl","pt-br","fi","es","nl","zh-hans","zh-hant","ar","cs","da","hu","it","ja","ko","no","pt","ro","sv","tr"]; if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(elt /*, from*/) { var len = this.length; var from = Number(arguments[1]) || 0; from = (from < 0) ? Math.ceil(from) : Math.floor(from); if (from < 0){ from += len; } for (; from < len; from++) { if (from in this && this[from] === elt){ return from; } } return -1; }; } //create onDomReady Event window.onDomReady = DomReady; //Setup the event function DomReady(fn){ //W3C if(document.addEventListener){ document.addEventListener("DOMContentLoaded", fn, false); }else{//IE document.onreadystatechange = function(){readyState(fn)} } } //IE execute function function readyState(fn){ //dom is ready for interaction if(document.readyState == "interactive"){ fn(); } } //location.href.lastIndexOf("/"); //location.href.length function onReady() { var loc = location.href.substring(location.href.lastIndexOf("/")+1,location.href.length); if (intcodes.indexOf(loc)){ x = document.getElementById('n-mainpage-description').children[0]; x.href = x.href + "/" + intcodes[loc]; } }