$(window).resize在IE中不起作用

时间:2012-05-03 10:21:18

标签: javascript jquery internet-explorer

我遇到问题$(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)
    }

});

1 个答案:

答案 0 :(得分: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");
    };

});
相关问题