The site I'm working on loads several iframes onto the page. When each iframe is loaded I want a function that is within the loaded iframe to change the height of that iframe. Most solutions for this type of issue seem to involve an id which won't work for me. jQuery(window).height() seems able to get the height of the iframe but cannot be used to set it. What I've tried This is code that I've put in the head of the iframe I want to change the height of.
jQuery(document).ready(function () { var newHeight = 500; jQuery(window).height(newHeight); window.innerHeight = newHeight; })
Note it's for a module and I can't put code in the parent page.... and it'll be tricky to add an id.
I'v also tried variations of this
jQuery('iframe', window.parent.document).each(function (){
var newHeight = aUniqueValue;
jQuery(this).attr("height",newheight); })
but this changes the height of all iframes to the last newHeight value of the last loaded iframe.
I seem to have worked out the solution which I couldn't find online:
jQuery(window.frameElement).height(newHeight);