我当前正在使用此脚本来在页面上放置特定的Cookie,该Cookie将被#aid =
网址中的令牌破坏我想做的是设置此cookie,以便在url中没有令牌的情况下将其作为默认的特定数字值。这就是现在的样子
<script type="text/javascript">
var isBuilderAll = false;
var query = location.hash;
if (query != '') {
if (query.indexOf('aid') >= 0) {
var reload = true;
if (query.indexOf("&") >= 0) {
var string = query.split('&');
query = string[0];
}
var date = new Date();
if (document.cookie.indexOf('AID#aid') >= 0) {
localStorage.setItem('aid', query.replace('#aid=', ''));
if (localStorage.getItem('aid-expires')) {
if (new Date().getTime() > localStorage.getItem('aid-expires')) {
_setAidStorage()
}
} else {
_setAidStorage()
}
date.setTime(localStorage.getItem('aid-expires'));
reload = false;
}
function _setAidStorage() {
var seconds = 60 * 60 * 24 * 90 * 1000;
localStorage.setItem('aid-expires', new Date().getTime() + parseInt(seconds));
}
document.cookie = 'AID' + query;
if (reload) {
location.reload(true);
}
}
}
</script>