I want to show a remote url's content or site in popup using iframe. But i do not want to fix height of iframe. I have already used some code
function resizeIframe(iframe) {
iframe.height = iframe.contentWindow.document.body.scrollHeight + "px";
}
for
and i have tried another code
document.getElementById('iframe1').scrollHeight();
But this is not working. Please suggest
Try this:
newheight = document.getElementById(iframe1).contentWindow.document.body.scrollHeight;
//For Firefox:
document.getElementById(id).height = (newheight) + "px";
//For Other:
$('#' + iframe1).css('min-height', newheight + 'px');
I think you missed style attribute:
iframe.style.height = iframe.contentWindow.document.body.scrollHeight + "px";
Or for the second I think you should do something like
$('#iframe1').height(300); //will set your Iframe height with id iframe1 to 300px
Otherwise
$('#iframe1').css("height", "300px") //do the same
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.