2012-05-03 79 views
0

我在$(window).resize中無法在Internet Explorer中工作時出現問題。我現在只在IE 8中檢查過。

基本上,我已經創建了一個函數,我們稱之爲calculate()。該函數根據窗口的當前寬度更改某些元素的寬度/高度。因此,該功能需要在準備好的文檔和瀏覽器的每個調整大小上調用。但是,當我調用函數窗口調整它不在IE中工作!但更奇怪的是,它在文檔準備就緒上完全正常工作,而不是在窗口大小調整上。

下面是代碼:

jQuery.noConflict(); 
jQuery(document).ready(function($){ 
    calculations(); // works fine here, it does all what it should do 

    $(window).resize(function(){ 
     calculations(); // works fine in all browsers except IE 
    }) 

    function calculations() { 
     //definition of function calculations here (i haven't pasted the exact function, all it does is change some widths and heights) 
    } 

}); 
+0

jquery.noConflict $重新分配,因此現在你的$不再提及jQuery的。 – Baz1nga

+0

'$'來自回調「就緒」功能,並且當前每個列出的代碼都是正確的。 – harningt

回答

0

可能:

var jNoConflit = jQuery.noConflict(); 
jNoConflit(document).ready(function(){ 
    calculations(); // works fine here, it does all what it should do 

    jNoConflit(window).resize(function(){ 
     calculations(); // works fine in all browsers except IE 
    }); 

    function calculations() { 
     alert("toto"); 
    }; 

}); 
+0

你可以編輯你的文章來解釋爲什麼/如何這是這個問題的潛在答案? –