Dynamically resize iframe

后端 未结 5 982
执笔经年
执笔经年 2020-12-30 05:32

Situation: I\'m working on a responsive design that involves the typical HTML/CSS combo. Everything is working nicely except in one case where there is an i

5条回答
  •  一个人的身影
    2020-12-30 06:33

    This is how I would do it, code is much shorter: http://jsfiddle.net/TBJ83/2/

    I did it that way for read-ability, but you could make it even shorter and faster...

    function setIFrameSize() {
        f = $("#myframe");
        f[0].setAttribute("width", f.parent().width());
        f[0].setAttribute("height", f.parent().height());
    }
    

    One selector, so you only look through the DOM once instead of multiple times.

提交回复
热议问题