javascript - 从 URL 中提取 - 长 URL

标签 javascript url

我目前正在尝试从 ReturnUrl= 中提取...我想使用 javascript 从下面的链接中提取 URL。有人可以帮忙吗?

http://testdealbuilderCCMS/questionnaire.aspx?db_template_reference=Construction: Westfield Services Agreement&ContractDescription=Facilities Contract&NatureServices=FACILITIES&SiteDescription=Retail Units&ThirdPartyAgreementsList=&ServiceFee=1000&ReturnUrl=http://localhost:4965&launcher.aspx?directLink=PX&caseKey=7ccef65756504a79bc3a4a6687c0d9555e519ec9079241c9944c6a523704&PXid=

最佳答案

这里有很多边缘情况会导致此失败。因此请小心,仅当您的字符串始终以 ReturnURL 参数结尾时才使用此选项。

找到ReturnURL=在字符串中的位置,然后获取从ReturnURL=位置+ReturnURL=长度到末尾的子字符串.

http://jsfiddle.net/3hvajedg/1/

the_string = 'http://testdealbuilderCCMS/questionnaire.aspx?db_template_reference=Construction: Westfield Services Agreement&ContractDescription=Facilities Contract&NatureServices=FACILITIES&SiteDescription=Retail Units&ThirdPartyAgreementsList=&ServiceFee=1000&ReturnUrl=http://localhost:4965&launcher.aspx?directLink=PX&caseKey=7ccef65756504a79bc3a4a6687c0d9555e519ec9079241c9944c6a523704&PXid=';

alert(the_string.substring((the_string.indexOf('ReturnUrl=')+'ReturnUrl='.length)));

关于javascript - 从 URL 中提取 - 长 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28605832/

相关文章:

javascript - 为什么闭包无法通过异步获得正确的外部值?

javascript - 整个页面加载后 slider 加载

javascript - 插入数据库时​​mysql连接超时(node.js)

javascript - 主机地址的正则表达式?

apache - 如何使网站在名称中没有 www 前缀的情况下工作?

java - 从移动设备指向 ebay.com 时出现 fileNotFoundException

javascript - Firebase 实时数据库分页

javascript - 用javascript中的图像填充圆形SVG元素

Android - 图片库(使用 Universal-image-loader)

Android webview loadDataWithBaseURL 如何从 Assets 加载图像?