2010-11-18 57 views
0
setInterval(function(){ 
    if(current_url == ''){ 
    window.location.hash = '#!/home'; 
    current_url = window.location.hash.href; 
    } 
    else if(current_url !== window.location){ 
    change_page(window.location.hash.split('#!/')[1]); 
    current_url = window.location.hash.href; 
    } 
},100) 

JavaScript的这部分/ jQuery使Mac上的Firefox看起来像是不断重新加载。在W7上的Firefox上它并没有和Chrome在两个操作系统上都能正常工作。我怎样才能让它停止看起来像加载在Firefox的真棒栏?在Firefox中使用jQuery的“AJAX”URL中的常量加载

仅供参考,即时通讯做这使前进/后退按钮功能的作品...

回答

2

试试这个:

var hashChanged = function() { 
    if(current_url == '') { 
    window.location.hash = '#!/home'; 
    current_url = window.location.hash; 
    } 
    else if(current_url !== window.location.hash){ 
    change_page(window.location.hash.split('#!/')[1]); 
    current_url = window.location.hash; 
    } 
}; 

if('onhashchange' in window) { 
    window.onhashchange = hashChanged; 
} else { 
    setInterval(hashChanged, 100); 
} 
+0

真棒奏效!谢谢你 – 2010-11-18 19:24:35

+0

@Oscar不客气! – 2010-11-18 19:25:46