iFrames, sliders, and resizing.

iFrames, sliders, and resizing.

Hi,


I have an iframe that when a page is loaded into it:


  1. function dslide(){$("#mainframe").slideUp(1000);}

The is called in links' onClick event. I have an auto-frame resizing system that was working before this, but after it, when a new page was loaded, it would set a height of 35, or only the first line on the page. However, if the page was previously loaded and the link is clicked again, the page loads fine. Help!


  1. function doIframe(){
  2. }

  3. pausecomp(50);
  4. o = document.getElementsByTagName('iframe');
  5. for(i=0;i<o.length;i++){
  6. if (/\bautoHeight\b/.test(o[i].className)){
  7. setHeight(o[i]);
  8. addEvent(o[i],'load', doIframe);
  9. }
  10. }
  11. pausecomp(50);
  12. $("#mainframe").slideDown(1000);
  13. }

  14. function setHeight(e){
  15. if(e.contentDocument){
  16. e.height = e.contentDocument.body.offsetHeight + 35;
  17. } else {
  18. e.height = e.contentWindow.document.body.scrollHeight;
  19. }
  20. }

  21. function pausecomp(millis)
  22. {
  23. var date = new Date();
  24. var curDate = null;

  25. do { curDate = new Date(); }
  26. while(curDate-date < millis);
  27. function addEvent(obj, evType, fn){
  28. if(obj.addEventListener)
  29. {
  30. obj.addEventListener(evType, fn,false);
  31. return true;
  32. } else if (obj.attachEvent){
  33. var r = obj.attachEvent("on"+evType, fn);
  34. return r;
  35. } else {
  36. return false;
  37. }
  38. }

  39. if (document.getElementById && document.createTextNode){
  40.  addEvent(window,'load', doIframe);

I tried
  1. if ($("#mainframe").height==35)
  2.       $("#mainframe").contentDocument.location.reload(true);
but no luck.