Elevation 3 using the concatenation of String parsing query string, online has a variety of regular way to parse, remember too much, the temporary need to write, they are confused. Just remember one, use the regular.
functionGetquerystringargs () {varSearch = (location.search.length > 0? location.search.slice (1): ""); varobj = {}; varreg =/([^?&=]+) = ([^?&=]*)/G; Search.replace (Reg,function(Match, $, $) { varName = decodeURIComponent ($); varval = decodeuricomponent ($); Obj[name]=Val; returnmatch; }); returnobj; }
Compatible with old browser getelementsbyclassname, note that this does not apply to multiple class names.
function Getelementsbyclassname (node, classname) {if(node.getelementsbyclassname) {returnnode.getelementsbyclassname (classname); } Else{var results= []; var elems= Node.getelementsbytagname (' * ')); for(var i = 0; i < elems.length; i++) { if(Elems[i].classname.indexof (classname)! =-1) {Results[results.length]=Elems[i]; } } returnresults; } }
Parse URL query string parameter as Object