[英]How do I grab a specific ID from a URL using javascript
I want to capture the values which proceeds 'tsid' from the below URL using javascript so in this case it would be '11693' is there a way to do this?我想使用javascript从下面的URL中捕获“tsid”的值,所以在这种情况下它将是“11693”有没有办法做到这一点?
www.foo.co.uk/search/clothing/c:29131/?ashd=AR422&_$ja=tsid:11693%7Cprd:%7Ccat:AR422 www.foo.co.uk/search/clothing/c:29131/?ashd=AR422&_$ja=tsid:11693%7Cprd:%7Ccat:AR422
You goona use PHP get values and seperate them with this function.你 goona 使用 PHP 获取值并使用此函数将它们分开。
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.