javascript resize iframe height dynamically issue -
i'm having issue resizing iframe fit content located within frame'd page. used suggestion found here resize frame dynamically.
in frame'd pages have
<body onload='parent.resizeiframe(getdocheight())'> function getdocheight() { var d = document; alert(d.url); return math.max( math.max(d.body.scrollheight, d.documentelement.scrollheight), math.max(d.body.offsetheight, d.documentelement.offsetheight), math.max(d.body.clientheight, d.documentelement.clientheight) );
}
and in page containing iframe have this
function resizeiframe(newheight) { var showsframe = document.getelementbyid('frm'); showsframe.style.height = parseint(newheight) +'px'; }
the function getting called correctly each frame'd page, reason 'newheight' parameter being passed keeping largest height value. example if have 2 frame'd pages 1 scroll height of 300px , other 500px. when first click link load 300px page works fine, if click link 500px page , try , come 300px page, value of 'newheight' remains @ 500. ideas? tia
i found issue having else experiencing same thing. because frame'd pages didn't have content scrollheight reporting length of entire document , not cutting content stopped. instead of trying calculate scrollheight, looked offsetheight correct height looking for. firebug nice tool inspect dom of each page , see values of each attribute without having write debugging messages. put line in every frame'd page
<body onload='parent.resizeiframe(getdocheight())'>
and in separate js file have code calculate height.
function getdocheight() { var d = document; return math.max( math.max(d.body.offsetheight, d.documentelement.offsetheight), );
Comments
Post a Comment