• IE中JS跳转丢失referer的问题


    在IE中,使用 location.href = "xxx.html" ,window.open("xxx.html") 这样的方式跳转页面时,在目标页面中 document.referer的值会是空。我们用两个方法解决

    1.form

    function URL(url) {
        if (isIE) {
            // IE浏览器
           var form= document.createElement("form");
            form.action = url;
            form.method = "GET";
            document.body.appendChild(form);
            form.submit();
        } else {
            // 非IE
            location.href = url;
        }
    }
    

    2.模拟a标签

    function URL(url, target) {
        var referer = document.createElement('div');
        referer.href = url;
        referLink.target = target;
        document.body.appendChild(referLink);
        if (isIE) {
            referLink.click();
        } else {
            window.open(url)
        }
    }
    

    参考:

    https://www.jb51.net/article/52350.htm

    https://www.cnblogs.com/qianyee/archive/2011/12/13/2286217.html

  • 相关阅读:
    两条斜线
    Cantor表
    城市网络
    一起来数二叉树吧
    牛客网音乐研究(枚举)
    删括号
    合并回文子串
    寻找道路
    EXTJS 4.0.2 XML数据
    extjs4.0.2a gridpanel看不到横向滚动条的一种原因
  • 原文地址:https://www.cnblogs.com/huahaiwujiang/p/13395704.html
Copyright © 2020-2023  润新知