How to create and manage complex nested frameset in javascript
-
I'm in the middle of developing a complex frames-based website. I'd noticed some Geocities-hosted pages using a javascript which dynamically writes the entire frameset in - this then means that javascript controls can be used to 'show' or 'hide' a frame. This is nice because it is the only method I know which works pretty well cross-browser. You can see an example of this here (a random geocities hosted site): http://www.geocities.com/chumps_53705/ Notice how the tab that controls the opening or closing is actually in a third (16 pixel wide) frame. I've taken the javascript as used by Geocities and cleaned it up and simplified it a lot - you'll find it below. However it only works with a single frameset. I need it to work with a nested frameset like this: <frameset rows="80,16,160,* cols="*"> <frame name="bannerFrame" src=""> <frame name="TAB1" src=""> <frame name="searchFrame" src=""> <frameset rows="*" cols="200,16,200,16,*"> <frame name="pane1" src=""> <frame name="TAB2" src=""> <frame name="pane2" src=""> <frame name="TAB3" src=""> <frame name="display" src=""> </frameset> </frameset> OR - the same effect acheived with an additional nested frameset would be acceptable: <frameset rows="80,16,160,* cols="*"> <frame name="bannerFrame" src=""> <frame name="TAB1" src=""> <frame name="searchFrame" src=""> <frameset name="set2" rows="*" cols="200,16,*"> <frame name="pane1" src=""> <frame name="TAB2" src=""> <frameset name="set3" rows="*" cols="200,16,*"> <frame name="pane2" src=""> <frame name="TAB3" src=""> <frame name="display" src=""> </frameset> </frameset> </frameset> I also need the final script to do a couple more things. What I'd like is code which works in a similar way to the geocities thing (see below for a link to cleaned up version I've done) BUT which additionally a) works with a nested frameset and b) adds the following functionality: * I need to be able to target any one of the frames from a link in any other frame; * if the targetted frame is 'collapsed' I also need the javascript to be clever enough to open it for me. * If a link is used to open or close a frame, I'd like the associated 'tab frame' to update the image accordingly. You can see a demo of the effect I want here, and check out the source to see the cleaned up / altered geocities script I used: http://www.qedstudio.com/frames/ I did this in a very dumb way in about 5 mins to show (partially) the effect I want from this script. As you'll see if you look at the code, although it looks fine, the frameset is actually being generated 3 times (!!) - which is bad. But it does demonstrate to you what I'm after. As well as this fundamental problem, I also haven't figured out how I'd be able to have a link in, say, the white frame which could target the black frame (say), AND open it if neccesary, AND change the image in the tab above to reflect the open/closed state of the black frame.
-
Answer:
Hi, paul. Thanks for your question. I've got some code that seems to do what you want. I've rewritten and commented it so it's much easier to understand. You can download it from http://hexx.net/ga/frameset.zip A few notes about my version: - The frameset that's written to the document initially is (almost) the same one that you supplied as the first example of a nested frameset. I removed the borders and changed a few of the names and ids, but it's the same layout. - It now uses cookies to store the open and closed tabs, and this information should persist for a year. (You mentioned it on your example page, and it wasn't too hard to implement). If you don't want this functionality, you can comment out the following lines: var framesetCookie = getCookie('fscookie'); saveCookie(); wherever they occur in the code. This will made the default frames appear whenever a user visits. - You can change the default frames shown by changing these lines (near the top): var searchFrameVisible = true; var listFrameVisible = true; var refineFrameVisible = false; - Links can either open in a frame and expand it, or open in a frame and keep it in the same state it was in before. Firstly, the frame names I've used: bannerFrame - the topmost banner frame (light blue in the example) searchTabFrame - the frame for the search expansion tab searchFrame - the search frame (black in the example) listFrame - the left pink expandable frame listTabFrame - the tab to open and close the left expandable frame refineListFrame - the right pink expandable frame refineListTabFrame - the tab to open and close the right expandable frame displayFrame - the big content frame If you want to change one, you can search and replace any of the names above. You need to replace every occurrence in the frameset.js file, and update the names of the expandable frames in the tab HTML files. To open a link in a frame without expanding it, use the following: <a href="[the url]" target="[frame name]">link</a> To open a link in a frame and expand it if possible, use: <a href="#" onClick="top.goToURL('[frame name]', '[the url]');return true;">link</a> Where [frame name] is the name of the frame from the list above, and [the url] is the address. I've included a few examples in the package. If I've misunderstood something or you have any questions, please don't hesitate to request a clarification. --wildeeo
paulv-ga at Google Answers Visit the source
Related Q & A:
- How to create deep object with dynamic name in Javascript?Best solution by Stack Overflow
- How to create an SlideShow in javascript?Best solution by Stack Overflow
- How to create dynamic function in javascript?Best solution by Stack Overflow
- How to access a nested function from another nested function in javascript?Best solution by devarticles.com
- How to create a complex doxygen alias?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.