11
A
回答
29
在我programming archive我有this function:
function querystring(key) {
var re=new RegExp('(?:\\?|&)'+key+'=(.*?)(?=&|$)','gi');
var r=[], m;
while ((m=re.exec(document.location.search)) != null) r.push(m[1]);
return r;
}
你可以使用它来获取查询字符串值和pu吨一个文本框:
$('#SomeTextbox').val(querystring('q'));
7
使用在the answer列出this question功能:
function getParameterByName(name)
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if(results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
然后就是做这样的事情:
var qParam = getParameterByName('q');
$('#mytextbox').val(qParam);
相关问题
- 1. jQuery的GET查询字符串的URL
- 2. jQuery:查询$ .get()返回的字符串
- 3. jQuery的构建HTTP查询字符串
- 4. JQuery的查询字符串遍历
- 5. jQuery的查询字符串对象
- 6. jQuery Mobile的查询字符串问题
- 7. 重定向查询字符串的URL非查询字符串
- 8. 查询字符串的查询字符串
- 9. jQuery Mobile,查询字符串导航
- 10. 查询字符串不使用jQuery
- 11. jQuery mobile:URL查询字符串不变
- 12. 如何使用jQuery查询字符串?
- 13. jquery greybox pass查询字符串
- 14. jquery移动查询字符串参数
- 15. Ajax - jQuery,数组查询字符串
- 16. 查询字符串
- 17. 查询字符串
- 18. 查询字符串
- 19. 查询字符串
- 20. 查询字符串
- 21. flask url_for()将查询字符串当作查询字符串
- 22. 使用查询字符串查询字符串列表?
- 23. 将查询字符串重定向到非查询字符串?
- 24. Python的查询(字符串)
- 25. mod_rewrite的查询字符串
- 26. servlet的查询字符串
- 27. mod_rewrite的查询字符串
- 28. .htaccess的查询字符串
- 29. ElasticSearch查询字符串查询default_operator
- 30. Grails域名字符串查询查询
看到这个问题:http://stackoverflow.com/q/901115/140185这一个:http://stackoverflow.com/q/585852/140185 – 2010-09-24 14:40:43
如果你传递GET变量,你使用什么服务器端脚本语言?如果你有一个服务器端脚本可用,那么使用PHP(或其他任何)来填充'textarea'可能比js/jQuery更容易。 – 2010-09-24 15:09:27