标签:var nbsp ++ result cti log length elements dex
高程3使用拼接字符串形式解析的查询字符串,网上有各种正则方式解析的,记得太多,临时需要写的时候,自己都搞混乱了。只记一种吧,用正则。
function getQueryStringArgs() { var search = (location.search.length > 0 ? location.search.slice(1) : ""); var obj = {}; var reg = /([^?&=]+)=([^?&=]*)/g; search.replace(reg, function (match, $1, $2) { var name = decodeURIComponent($1); var val = decodeURIComponent($2); obj[name] = val; return match; }); return obj; }
兼容老浏览器的getElementsByClassName,注意这个不适用于多个类名。
function getElementsByClassName(node, classname) { if (node.getElementsByClassName) { return node.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]; } } return results; } }
标签:var nbsp ++ result cti log length elements dex
原文地址:http://www.cnblogs.com/zhansu/p/6681492.html