如下所示:
function getArgs(strParame) { var args = new Object( ); var query = location.search.substring(1); // Get query string var pairs = query.split("&"); // Break at ampersand for(var i = 0; i < pairs.length; i++) { var pos = pairs[i].indexOf('='); // Look for "name=value" if (pos == -1) continue; // If not found, skip var argname = pairs[i].substring(0,pos); // Extract the name var value = pairs[i].substring(pos+1); // Extract the value value = decodeURIComponent(value); // Decode it, if needed args[argname] = value; // Store as a property } return args[strParame]; // Return the object }
使用例程:
default.aspx?ID=111
var x = getArgs("ID");
x的值就為:111
以上就是小編為大家帶來的通過JS獲取Request.QueryString()參數的值實現方法的全部內容了,希望對大家有所幫助,多多支持~