PDA

View Full Version : Changing contents in one iFrame after another loads


paulkeates
03-15-2006, 11:50 AM
Hi,

Yes, I've search thoroughly for an answer - maybe I'm missing it? Yes, also I'm new at this. I will make an exceptional effort to be both clear and concise.

Environment: FrontPage 2003.

I have 5 buttons and two vertical iFrames on a single page. The buttons are 'button 1' through 'button 5'.

The left iFrame is called 'menu', the right is called 'display'.
There are 5 possible menus that can be loaded to the 'menu' iFrame - depending on which of the 5 buttons are pushed.

The 'menu' (left) iFrame is preloaded with the first menu that would be loaded by pushing button 1. The 'display' (right) iFrame is preloaded with default display contents that would be loaded by clicking the first link on menu 1.

Great - both the menu and the display pages appear when the site loads.

When I push button 2 it loads the proper menu associated with button 2 to the left 'menu' iFrame. Great. This works.

Currently, it will keep the old 'display' (right) iFrame contents until the user clicks a link in the 'menu' (left) iFrame.

What I need it to do is automatically update the 'display' (right) iFrame to display the page that would be displayed if the user had clicked the first link of menu 2.

Then, when button 3 is pushed it would load the third menu set to the left 'menu' iFrame and also automatically load the appropriate first page to the right 'display' iFrame.

I've investigated the 'onload' event and people state that this is only triggered the first time that a frameset loads, so it won't work (I think?). If it is only triggered once, on frameset loading, then it will never update when other menu's are loaded.

Could it be linked to 'unload' so that when the contents of 'menu' changes the appropriate page in 'display' gets loaded as well?

As I stated, I'm new at this but willing to help others in any way needed. I'll trade my testing / QA skills for an answer to my problem.

Thanks in advance,

Paul

SpirtOfGrandeur
03-15-2006, 01:34 PM
onload triggers correctly in IE and FF. For I use it in both. But what you actually want to do is have at the end of your menu script a window.open that loads the other frame. This will make it alot easier on you.


JS: (Bottom of Menu pages)
<script type='text/javascript'>
window.open('./firsturlhere.html', 'display');
</script>

paulkeates
03-18-2006, 04:12 AM
An update because I solved the issue an want to make it available to others who might be looking for the answer.

Yes, I know it is not much (one line!), but there is no clear answer to this after a lot of searching. Every little bit helps!

<script type=text/javascript>;
parent.frames['displayframe'].location = "displayframe_overview_what_we_do.htm"
</script>

You place this at the very bottom of the HTML that gets loaded in order to display the menus. The 'displayframe' part references the actual iFrame that you want to load a html page into. The last part of the statement is the actual URL to load into that page.

So you use this code to load one (or as many as needed) iFrames with URL's after an iFrame has been loaded. This is very useful for dynamically building menus with associated 'hit lists' alongside to help you quickly narrow down your options.

To see the actual implementation go to www.sqa-one.com and view source of any of the menus as they load.

Thanks to 'SpirtOfGrandeur' for answering part of this in his prior post - the point about 'performing an operation at the end of the menu load' instead of looking ofr an event to be triggered.

Thanks,

Paul