Rocho.J

人脑是不可靠的, 随时记录感悟并且经常重复!

 

Request.UrlReferrer为空的解决 [转自: http://hkstb.blog.163.com/blog/static/4609679320102174910325/]

Request.UrlReferrer为空的解决 

2010-03-17 16:09:10|  分类: 技术讨论 |  标签: |字号  订阅

问题:
   在IE6下,如果前一个页面使用了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;  

posted on 2011-06-29 14:04  RJ  阅读(250)  评论(0)    收藏  举报

导航