Request.UrlReferrer为空的解决

问题:
   在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 @ 2011-08-31 18:41  陌香  阅读(3068)  评论(1编辑  收藏  举报