使用js 将82d4b917f84ecf2d00295f5d96ec3b41f163-169381647333222&type=recovery 根据tpye跳转并且携带&前的参数
您可以使用JavaScript的window.location.href方法来根据type参数进行页面跳转,并携带&前的参数。
以下是一个示例代码:
// 获取URL中的参数
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
// 获取type参数的值
var type = getParameterByName('type');
// 根据type参数进行跳转
if (type === 'recovery') {
var parameter = window.location.href.split('&')[0];
window.location.href = 'http://example.com/recovery?type=' + type + '&' + parameter;
} else {
// 其他情况的跳转
window.location.href = 'http://example.com';
}
请将http://example.com/recovery和http://example.com替换为您实际想要跳转的URL
原文地址: http://www.cveoy.top/t/topic/iXDv 著作权归作者所有。请勿转载和采集!