确定何时更改元素的实际宽度/高度

时间:2011-01-31 20:59:20

标签: javascript jquery iframe modal-dialog

我正在处理在iframe中打开的一些模态(相同的域,因此没有xss问题)。我所拥有的模式之一是根据你做的事情隐藏或显示选项,这些选项会增加或缩小表单。无论如何,长话短说我有代码处理基于当前负载上的身体的当前高度/宽度调整iframe的大小。问题是我不确定在初始加载后确定主体的实际尺寸发生了变化的事件。

1 个答案:

答案 0 :(得分:0)

为什么不添加setInterval()?类似的东西:

var originalWidth = {set original width}
var originalHeight = {set original height};
setInterval(function(){
    var currentWidth = {grab new values};
    var currentHeight = {grab new values};
    if(originalWidth !== currentWidth){
        //Change the width now...
        //Next, set originalWidth to be the same as current for future checks
        originalWidth = currentWidth;
    }
    //Now, do the same for original and current height
},100)
相关问题