Friday, 9 August 2013

Dynamically change height of iframe based on height on content

Dynamically change height of iframe based on height on content

I'm trying to find an elegant solution that will change the height of an
iframe based on the height of the content that appears inside it.
var windowheight = window.innerHeight;
var new_height = JSON.stringify({"height": windowheight });
top.postMessage(new_height, location.protocol +"//www.youtube.com/");
The above is what I have been trying to use however its not working,
returning a height value of 600px which is not nearly enough. The iframe
is not on the same domain but it does have a consistent iframe ID, which
seems to be used in other methods I have researched.
Any ideas greatly appreciated!
thanks

No comments:

Post a Comment