可能重复:
Get query string values in JavaScript通查询字符串的WebMethod在Javascript
是什么让 “测试1” 从
的最佳方式
,并通过PageMethod传递给web方法。我认为一种方法是从window.location.pathname中取出,剪切字符串并将其作为参数传递。
可能重复:
Get query string values in JavaScript通查询字符串的WebMethod在Javascript
是什么让 “测试1” 从
的最佳方式
,并通过PageMethod传递给web方法。我认为一种方法是从window.location.pathname中取出,剪切字符串并将其作为参数传递。
可能是你只能使用的JavaScript,如:
var search = function(){
var s = window.location.search.substr(1),
p = s.split(/\&/),
l = p.length,
kv, r = {};
if(l === 0){return false;}
while(l--){
kv = p[l].split(/\=/);
r[kv[0]] = kv[1] || true;
}
return r;
}();
然后在你的代码中使用search.username
尝试
string username = Request.QueryString["username"];
在PageMethod的,你可以做
string username = HttpContext.Current.Request.QueryString["username"];
是的,我尝试第二个,但我得到空。 – gormit
看看这里:http:// stackoverflo w.com/questions/901115/get-query-string-values-in-javascript – Mrchief