页面链接跳转不记录历史

function fnUrlReplace(href) {
    if (href && /^#|javasc/.test(href) === false) {
        if (history.replaceState) {
            history.replaceState(null, document.title, href.split('#')[0] + '#');
            location.replace('');
        } else {
            location.replace(href);
        }
    }
};

fnUrlReplace(targetURL);

fnUrlReplace后面直接写一个链接,这样既可以跳转又不会记录历史,而且还做了兼容性处理,兼容到IE6。

你可能感兴趣的:(页面链接跳转不记录历史)