Request.UrlReferrer为空的解决

来源:互联网 发布:个人记账软件 pc 编辑:程序博客网 时间:2024/06/09 19:26

在IE6,7,8,360下,如果前一个页面使用了window.location方法导航到第二个页面,那么第二个页面的Request.UrlReferrer将为空。
但是IE6以上,FireFox,Chrome等不出现这个问题,使用window.location方法后第二个页面的Request.UrlReferrer仍能得到正确的值。

//跳转
function GetJump(url) {
//判断是IE且版本小于7
    //下面这句只支持win2003和win2008平台,win xp有问题
    //if (getIEVersion() < 7 && getIEVersion() > 0) {
    //下面支持各平台
    if (getIEVersion() > 0) {
        var tempa = document.createElement("a");
        tempa.href = url;
        document.getElementsByTagName("body")[0].appendChild(tempa);
        tempa.click();
    } else {
//其它浏览器直接导航
        window.location.href = url;
    }
}
function getIEVersion() {
    var rv = -1; // Return value assumes failure. 
    if (navigator.appName == "Microsoft Internet Explorer") {
        var ua = navigator.userAgent;
        var re = new RegExp("MSIE ([0-9]{1,}[/.0-9]{0,})");
        if (re.exec(ua) != null)
            rv = parseFloat(RegExp.$1);
    }
    return rv;
}

原创粉丝点击