2011-06-20 104 views
-1

我使用的是当前的jQuery插件(地址),我有这样的代码(我用的地址插件“搜索引擎优化”方法)无限循环 - jQuery插件(地址)

$(document).ready(function() { 
    $.address.crawlable(1).state('/').init(function() { 
     $('body').delegate('.ajax', 'click', function() { 
      $('.ajax').address(); 
     }); 
     $('.ajax').address(); 
    }).change(function(e) { 
     var loc = document.location.href; 
     if (loc != 'http://secret.riseofkings.net' + e.value) { 
      var myStr = e.value; 
      myStr = myStr.substr(1); 
      if (myStr) { 

       $("#content").html('<img src="/images/ajax.gif" />'); 
       $("#iframe_space").html('<iframe src="http://riseofkings.net/nothing.php" style="display:none"></iframe>'); 
       var url = $(e).val().toLowerCase().substr(1).replace(/ /g, '%20'); 
       $("#content").load(url + '&ajax=1', function() { 
        $("#iframe_space").html(''); 
       }, function(errr) { 
        alert('Something went wrong. Sorry for problems'); 
       }); 
      } 
     } 
    }); 
}); 

UPDATE:

当我尝试添加

alert(loc+' vs http://<?php echo $security->host()."'"; ?>+e.value);

if (loc != 'http://secret.riseofkings.net' + e.value) { 

它给了我http://secret.riseofkings.net/game.php VS http://secret.riseofkings.net/ 当我去链接(/game.php?what=map)它提醒http://secret.riseofkings.net/game.php VS http://secret.riseofkings.net/game.php?what=map

ENDUPDATE;

UPDATE2:

发生这种情况,例如在Mozilla/5.0 (Windows; U; Windows NT 5.1; cs; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2

ENDUPDATE;

但在某些Firefox版本(3.XX)和IE中存在无限循环。我确实访问了主页,并开始重新加载并在地址栏中追加地址末尾的#/game.php?r=something

你不知道那里有什么问题吗?

回答

1

那么这条线:

clearTimeout = window.clearTimeout(timer); 

是错误的,可怕的;应该只是:

clearTimeout(timer); 
+0

问题与新的代码(删除setTimeout和clearTimeout completelly)更新 – genesis

+0

我会再看看... – Pointy

0

我有我的asp.net MVC网站中的JQuery地址类似的问题。如果我点击回到一个散列网址的页面,它会吓坏了,并无休止地循环页面。事实证明这个问题与mvc标准版的MicrosoftAjax.js和MicrosoftAjax.debug.js文件的旧版本有关。

如果打开MicrosoftAjax.debug.js文件,你会看到文件版本:4.0.20526.0(这是与MVC模板默认版本),然后再升级从CDN(http://www.asp.net/ajaxlibrary/CDNAjax4.ashx

调试和压缩版本请注意,这个解决方案在堆栈溢出中发现在另一个问题,所以它不是我的解决方案。即时通讯试图找到原来的问题,谁给出了解决方案。

编辑:Firefox 6 Infinite Page Refresh With Page With Hash Tags