iFrames, sliders, and resizing.
Hi,
I have an iframe that when a page is loaded into it:
- 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!
- function doIframe(){
- }
- pausecomp(50);
- o = document.getElementsByTagName('iframe');
- for(i=0;i<o.length;i++){
- if (/\bautoHeight\b/.test(o[i].className)){
- setHeight(o[i]);
- addEvent(o[i],'load', doIframe);
- }
- }
- pausecomp(50);
- $("#mainframe").slideDown(1000);
- }
- function setHeight(e){
- if(e.contentDocument){
- e.height = e.contentDocument.body.offsetHeight + 35;
- } else {
- e.height = e.contentWindow.document.body.scrollHeight;
- }
- }
- function pausecomp(millis)
- {
- var date = new Date();
- var curDate = null;
- do { curDate = new Date(); }
- while(curDate-date < millis);
- }
- function addEvent(obj, evType, fn){
- if(obj.addEventListener)
- {
- obj.addEventListener(evType, fn,false);
- return true;
- } else if (obj.attachEvent){
- var r = obj.attachEvent("on"+evType, fn);
- return r;
- } else {
- return false;
- }
- }
- if (document.getElementById && document.createTextNode){
- addEvent(window,'load', doIframe);
I tried
- if ($("#mainframe").height==35)
- $("#mainframe").contentDocument.location.reload(true);
but no luck.