本文为大家详细介绍下如何通过JavaScript实现QueryString获取GET参数
具体实现如下
感兴趣的朋友可以参考下哈
希望对大家有所帮助
复制代码 代码如下:
<div id="page">
<select name="select
" id="select
type">
<option value="
">请选择</option>
<option value="
">企业</option>
<option value="
">产品</option>
</select>
</div>
复制代码 代码如下:
QueryString = {
data: {}
Initial: function () {
var aPairs aTmp;
var queryString = new String(windowlocationsearch);
queryString = queryStringsubstr( queryStringlength); //remove "?"
aPairs = queryStringsplit("&");
for (var i = ; i < aPairslength; i++) {
aTmp = aPairs[i]split("=");
thisdata[aTmp[]] = aTmp[];
}
}
GetValue: function (key) {
return thisdata[key];
}
}
$(function () {
//初始化
QueryStringInitial();
var type = QueryStringGetValue("type");
if (typeof (type) != "undefined") {
$("#selecttype")val(type);
}
$("#selecttype")bind("change" function () {
var row = $(this)find("option:selected")val();
//alert(row);
if (row == )
locationhref = "?type=" + row;
if (row == )
locationhref = "?type=" + row;
});
});