PDA

View Full Version : changing external content based on window content



mcpalmer
04-27-2005, 12:45 AM
Is it possible to change content outside of a scrollbar window when the window contents change? For example the window contains a list of cake recipes. There is a full list of all the recipe titles outside the window. The recipe title highlighted will change depending on what recipe text is currently in the window. Can anyone give me any clues/links to demos as to how to go about doing this?

jscheuer1
04-29-2005, 07:30 PM
The contained page can access a function on the container page like so:


window.parent.functionname()

Armed with this knowledge, you can have on each recipe page:


<body onload="window.parent.highlight('recipe_name')">

"recipe_name" could simply be the id of the item on the parent page to be highlighted. Then put a function on the container page called highlight:


highlight(r_name){
code here to highlight whatever you want
}

This seems a bit extraneous to me though, how else would a recipe get loaded in the iframe without someone clicking on its name on the parent page? Unless there is some other way, a simple onClick event on the parent page will take care of this.

If you are using frames, not iframes, use:


parent.window.framename.functionname()