[英]jquery - check if query string present on URL?
是否可以使用jquery(或只是javascript)来检查URL上是否存在查询字符串?
document.location
包含有关URL的信息, document.location.search
包含查询字符串,例如?foo=bar&spam=eggs
。 至于测试它的存在,如何:
if(document.location.search.length) {
// query string exists
} else {
// no query string exists
}
不需要jQuery:o
我认为你可以使用javascript匹配运算符。
var url = window.location.search;
if (url.match("your string").length > 0) {
}
查看http://rixi.us/post/791257125/get-and-server-free-dynamic-contet
提取任何查询字符串参数的方法
使用::
if (_GET['key']) {
var key = _GET['key']
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.