开发者

Determine when the actual width/height of an element is changed

I'm dealing with some modals that are opened up in an iframe (same domain, so no xss issues). One of the modals I have either hides or shows options based on things you do which grows or shrinks the form. Anyway, long story short I have the code that handles resizing the iframe based on the current height/width of the bod开发者_运维问答y on the inital load. The problem is that I'm not sure what event to tap into to determine that the body's actual size has changed after the initial load.


Why not add a setInterval()? Something like:

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜