2011-06-20 153 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