Forum Moderators: open

Message Too Old, No Replies

Opening frames from the code in other frames

Frames Help!

         

ouik

6:08 am on May 11, 2006 (gmt 0)



I'm trying to get the 'top' frame on my page to update when something is changed in the 'body' frame. Is this possible? e.g. when someone clicks a link which opens in the 'body' frame, I'd like the 'top' frame (which contains the page title) to correspond with that in the 'body' frame...

any help would be very appretiated!

tedster

5:46 pm on May 11, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to the forums, oiuk.

There is no way to change two frames at once with basic html. However, you can accomplish this with javascript. One approach is outlined in our Javascript Forum's Library thread, Handy, generic javascript coding [webmasterworld.com] in post #17

CHANGING TWO FRAMES
from one link

Assume you've named the frames to be changed frame1 and frame2 and the HTML files to be loaded into those frames are newpage1.html and newpage2.html.

1. FUNCTION definition
(this goes in the HEAD section or .js file for the HTML of the navigation frame)

function doTwo(pageA,pageB)
{
(parent.frame1.location=pageA);
(parent.frame2.location=pageB);
}

2. LINK
(code for the HTML page)

<a href="javascript:doTwo('newpage1.html','newpage2.html')">ONE LINK changes two frames</a>

3. WEIRD STUFF
The BACK button will only take the screen back one frame at a time, not both at once. If that's a problem, the only workaround I can think of is forgetting the Javascript and having the link load an entirely new frameset, with the individual frames holding the new HTML documents (and the old documents, for any frames that will remain the same)