如下所示:
function getArgs(strParame) {var args = new Object( );var query = location.search.substring(1); // Get query stringvar pairs = query.split("&"); // Break at ampersandfor(var i = 0; i < pairs.length; i++) {var pos = pairs[i].indexOf('='); // Look for "name=value"if (pos == -1) continue; // If not found, skipvar argname = pairs[i].substring(0,pos); // Extract the namevar value = pairs[i].substring(pos+1); // Extract the valuevalue = decodeURIComponent(value); // Decode it, if neededargs[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()参数的值实现方法的全部内容了,希望对大家有所帮助,多多支持武林网~
新闻热点
疑难解答