jQuery height function not working in thickbox iFramed content? try this


Last week we were trying to run a scroll script (DYN-WEB’s scrolling code ) inside thickbox iFramed content. Unfortunately code was not working and the reason was the element height not working. We tried alternative jQuery element height and the result was same. The height we were getting was ‘0′.

Finally we fixed this issue by using setTimeout and calling the scroll script after a small delay.

 $(function() {
    	alert($(".box").height()); // not working, what we got was '0'
    	setTimeout('alert($(".box").height());',500); // worked
 
  })

Hope this may help someone :)

,

  1. #1 by Remiz - March 29th, 2009 at 12:43

    I think the height is applying only after some content loads in it. That is why at document ready, it is zero and once the content loads (ie, after 5 seconds) it become the size of content.

    • #2 by Nishanth - March 29th, 2009 at 12:58

      yes, so we used setTimeout to delay the funcion call :)

(will not be published)
  1. No trackbacks yet.