熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

JavaScript實現QueryString獲取GET參數的方法

2013-11-15 12:14:51  來源: JSP教程 
本文為大家詳細介紹下如何通過JavaScript實現QueryString獲取GET參數具體實現如下感興趣的朋友可以參考下哈希望對大家有所幫助   復制代碼 代碼如下:
<div id="page">
<select name="select" id="selecttype">
<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;
});
});


From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20568.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.