简体   繁体   English

如何使用 javascript 从 URL 中获取特定 ID

[英]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.

相关问题 如何使用JavaScript从URL抓取任何句段? - How do I grab any segment from URL using Javascript? 如何从输入框中获取一些输入,放置在变量中,然后使用HTML和Javascript输出到范围ID? - How do I grab a few inputs from input boxes, place in variables, then output to a span id using HTML & Javascript? 如何使用 javascript 从 MongoDB 获取一个带有 ID 的文档 - How do I get one document from MongoDB with ID from URL using javascript 如何使用jQuery和Waypoint获取$ this的ID - How do I grab the ID of $this using jQuery and Waypoints 如何使用JavaScript从URL中获取JSON数据? (JSON的新功能) - how to grab JSON Data from url using JavaScript? (new to JSON) 如何从数据库Firebase抓取推送ID - how do i grab push ID from database firebase 使用 JavaScript,如果 URL 中提供了 id,我如何突出显示标签 - Using JavaScript, How do I highlight a tag if the id is provided in URL 如何从javascript中的网址获取ID号? - How do I get id number from url in javascript? 如何使用jQuery和JavaScript获取URL的特定部分? - How do I get the specific part of a URL using jQuery and JavaScript? 如何从特定频道获取附件网址? - How to grab an attachment url from a specific channel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM