You can load pages into the two frames in the frameset because they are there. However, the iframe isn't there until the page that has the iframe is in the frame into which it is being loaded and that page is parsed by the browser. Assuming the iframe is on the page loaded into the content frame and is a named iframe one could do:
Code:
function loadFrames(frame1,page1,frame2,page2,frame3,page3,frame4,page4) {
parent[frame1].location = page1;
parent[frame2].onload = function(){
parent[frame2].frames[frame3].location = page3;
parent[frame2].onload = function(){};
};
parent[frame2].location = page2;
}
But, if there is not always an iframe on the second page, you will have an error in those cases. And if the second page has its own onload function, it will overwrite the one in the above function before it's executed. These issues could be overcome by using version 5 events for the load event and testing for the existence of the iframe before trying to load to it. To do that, replace the above with:
Code:
var addEvent = (function(){return window.addEventListener? function(el, ev, f){
el.addEventListener(ev, f, false);
}:window.attachEvent? function(el, ev, f){
el.attachEvent('on' + ev, f);
}:function(){return;};
})();
var removeEvent = (function(){return window.removeEventListener? function(el, ev, f){
el.removeEventListener(ev, f, false);
}:window.detachEvent? function(el, ev, f){
el.detachEvent('on' + ev, f);
}:function(){return;};
})();
function loadFrames(frame1,page1,frame2,page2,frame3,page3,frame4,page4) {
parent.frames[frame1].location = page1;
function loadIframe(){
if(frame3 && page3 && this.frames[frame3]){this.frames[frame3].location = page3;}
removeEvent(this, 'load', loadIframe);
}
addEvent(parent.frames[frame2], 'load', loadIframe);
parent.frames[frame2].location = page2;
}
There's a lot that might go wrong with this, but the idea is sound. So, if there are problems they can probably be worked out.
The browser cache may need to be cleared and/or the page refreshed to see changes.
If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
Bookmarks