1

I have a little problem. On my aspx page I have an iframe which contains grids, tables, etc and they always change their height obviously. The previous developer team solved the problem, that they set the height attribute of the iframe to constant 3500px. It's not so elegant way so I added a JS code, that automatically checks the content and adjust the iframe height. I got the JS script from here:

iframe Auto Adjust Height as content changes

The issue is that, this js code works well in Chrome and Firefox and almost everytime in IE. Sometimes I got an error message in IE that says: "unable to get property 'nodename' of undefined or null reference jquery" or "Invalid argument". From this time somehow the function inside the setInterval will never run again and that's why the iframe height will never be adjusted. I made some modification and this height checking function is called from body onload event. Theoretically this js script will run when the whole dom structure is loaded. Firefox and Chrome is Ok, and 8 times from 10 IE also works.

Can somebody help me? Is there any solution you can suggest me? Thanks a lot.

Community
  • 1
  • 1

1 Answers1

0

Execute your code within to ensure that it executes when the full page has been constructed:

$(document).ready(function(e) {

    // .. iframe resize here
});

Sporadic failures like this on page load are almost always caused by executing JavaScript before the page is loaded and the DOM is ready.

Luke
  • 19,970
  • 26
  • 98
  • 180
  • Hi Coulton, previously I also tried this, but the result was the same. Now I advised to the others, use Chrome or Firefox. Temporarily I modified the code and before the setInterval part I check for the browser. In case of IE the height will be set to 3500 px othervise the JS code will be executed. – Gergely Halász Oct 07 '15 at 11:16