How can i change the size of an iframe from inside?

前端 未结 3 1127
-上瘾入骨i
-上瘾入骨i 2020-12-25 12:20

I\'m developing with jquery and I stumbled with the next problem: I added an IFrame inside the main page and I want to re size them from inside. I tried some ideas but witho

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-25 12:51

    function setHeight() {
        parent.document.getElementById('the-iframe-id').style.height = document['body'].offsetHeight + 'px';
    }
    

    Another way using Javascript

    document.getElementById("ifr").height= "500px";
    document.getElementById("ifr").width= "500px";
    

    DEMO JSFIDDLE

提交回复
热议问题