Skip to content

Commit

Permalink
Try a simpler algorithm for resizing IFRAME
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Sep 26, 2013
1 parent b224b88 commit 985ee58
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions imp/js/imp.js
Expand Up @@ -122,23 +122,10 @@ var IMP_JS = {

iframeResize: function(id)
{
if (!(id = $(id))) {
return;
}

var lc = id.contentWindow.document.lastChild,
body = id.contentWindow.document.body;

lc = (lc.scrollHeight > body.scrollHeight) ? lc : body;

// Try expanding IFRAME if we detect a scroll.
if (lc.clientHeight != lc.scrollHeight ||
id.clientHeight != lc.clientHeight) {
id.setStyle({ height: lc.scrollHeight + 'px' });
if (lc.clientHeight != lc.scrollHeight) {
// Finally, brute force if it still isn't working.
id.setStyle({ height: (lc.scrollHeight + 25) + 'px' });
}
if (id = $(id)) {
id.setStyle({
height: ((Element.getHeight(id.contentWindow.document.lastChild) + 10) + 'px')
});
}
},

Expand Down

0 comments on commit 985ee58

Please sign in to comment.