您的位置:首页 > Web前端 > JavaScript

原来定义JS类库这么简单

2014-08-15 16:55 274 查看
var JSMethod = {
getUrlParam: function (strname) {//从URL获取参数
var hrefstr, pos, parastr, para, tempstr;
hrefstr = window.location.href;
pos = hrefstr.indexOf("?");
parastr = hrefstr.substring(pos + 1);
para = parastr.split("&");
tempstr = "";
for (i = 0; i < para.length; i++) {
tempstr = para[i];
pos = tempstr.indexOf("=");
if (tempstr.substring(0, pos) == strname) {
return tempstr.substring(pos + 1).replace("#", "");
}
}
return null;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: