Skip to content

Instantly share code, notes, and snippets.

@rankun203
Created October 27, 2014 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rankun203/04a457cdf25049b2f459 to your computer and use it in GitHub Desktop.
Save rankun203/04a457cdf25049b2f459 to your computer and use it in GitHub Desktop.
iFrame resize parent height.
if(parent.frames.length == 0) {
// AW: always be inside a Colnect page
var dst = location.href.replace(/\/forums/, '/forum').replace(/\.php[\?]?/, '!');
top.location.replace(dst);
} else {
try {
url = parent.location.href;
pos = url.search(/\/\w\w(\W|$)/);
lang = url.substring(pos+1,pos+3);
dst = location.href.replace(/\/forums/, '/'+lang+'/forum').replace(/\.php[\?]?/, '!').replace(/lang=\w\w&?/, '');
window.setTimeout( function(){
// Update parent page url to correct forum url
parent.history.replaceState(null, "Forum", dst);
// Resize the frame we're in before it's fully loaded (images...)
var iFrames = parent.document.getElementsByTagName('iframe');
iFrames[0].style.height = iFrames[0].contentWindow.document.body.offsetHeight + 'px';
}, 10 );
} catch(e) { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment