我目前正在尝试从 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/