Created
October 27, 2014 07:57
-
-
Save rankun203/04a457cdf25049b2f459 to your computer and use it in GitHub Desktop.
iFrame resize parent height.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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