JavaScript删除URL指定的参数和值,不跳转
(function handleLocationHref () { var url = window.location.href; var params = (window.location.search || '?').substring(1).split('&'); var prefix = url.substring(0, url.indexOf('?')); var suffix = ''; var filterParams = ['user', 'password']; for (var i = params.length - 1; i >= 0; i--) { var param = params[i]; var key = param && param.split('=', 2)[0]; if (!param || filterParams.indexOf(key) !== -1) { params.splice(i, 1); } } if (params.length) { suffix = '?' + params.join('&'); } window.history.replaceState({}, '', prefix + suffix); })();
标签:suffix,删除,URL,JavaScript,param,window,params,var From: https://www.cnblogs.com/gdjlc/p/17217615.html