View Full Version : Content progression

01-30-2007, 06:32 AM
Hi everyone!,

This is my first post on dynamic forums, i have browsed and used dynamic drive solidly for the last two years. It is a great resource. I am purley a designer, css and html literate and the usal design software.

I am designing a site at the moment and trying to find some sort of javascript solution to an idea.

The site has a menu at the top and three panels (divs) below. What we want to happen is have some one choose a menu option and load it in panel one, choose another menu option and load it in panel two, choose another menu option and load it in panel three, then back to panel one, so the user can continue to view there previous choices.

Any ideas or suggestions would be much appreciated. Would it be easy to adapt a random content script to a cycling content script.

If this is not the right forum for this let me know.


01-30-2007, 02:53 PM
An interesting idea. I quite like it.

It's certainly possible. What, though, do you mean by "load?" Where is this data coming from? Is it an external page, or is it stored in a Javascript variable?

01-31-2007, 01:15 AM
By loading i ment having the content in a div and getting it to appear in the desired colum. Could also be nice to do it with XML.

Would someone be willing to help me out with this?


02-01-2007, 01:46 PM
Why not place three <iframes> ?

02-01-2007, 10:41 PM
Why not place three <iframes> ?

Would this allow me to cycle information across the three iFrames?

I have been advised about avoiding iFrames from teachers and other designers.

02-01-2007, 11:31 PM
Could do it in Flash. Heh :D

02-02-2007, 05:31 AM
Could do it in Flash. Heh :D
It could be done in basic aswell :D . Nah flash has crossed my mind and i could do it that way myself, but its not friendly way to do it, flash player reliant but the same problem with java script disabled browsing. Ajax would be a dream. Looks beeter than flash. Anyway i may have to settle for something a little less ambitious.

02-02-2007, 10:31 AM
Ajax, Flash and Javascript are all 'more' than iframes.
It's best to avoid EVERYTHING that you don't need. The exceptions would be PHP (as it outputs pure html from the server, no programming, so it's always consistant, not user dependant and doesn't vary by browser/OS) and ASP JSP etc., and CSS (since it's very widely supported and generally helpful).

But in short, don't use what you don't need. Ajax especially causes problems. I assure you, iframes will be more supported than ajax. Likely all browsers that support any javascript will support iframes. And iframes can't just be disabled, like javascript can be. (I don't think so anyway.)
Flash and other similar things require plugins. I avoid them if at all possible. Your visitors won't see a thing without the plugin.

So... what's the answer? Keep it simple. All you need here is an iframe and some basic javascript.

Just target the links (all of 'em) to the 'main' or 'first' iframe. I'd suggest maybe the middle one in case the javascript doesn't work so it keeps it centered. I'd have some nice background on a blank page for the other two frames while they aren't used for holding content (unless you load some content to start).
Now, for each link also include an onClick attribute, something like onClick="return loadme(this.href);" which will call a function and send as a value the location for the link, while returning it, NOT the original thing (meaning loading the page). If javascript DOES fail, it's a nice fallback as it'll still load normally.
For the function, you should just use, basically:
function loadme(url) {
if (framecount&#37;3 == 0) framenum = 2; //start frame
else if (framecount%3 == 1) framenum = 3; //next frame
else framenum = 1; //third frame
window.framename.location = url;

1. I don't know if the last line is right. I don't do JS that much. But if you wrote that correctly, this would work, and well.
2. framecount must be set as a global value, so it keeps track each time, not just for each occurance of the function.
3. I believe the modulus operator exists in javascript. Should give the remainder. I hope. PHP does that, anyway.
4. Braces left off the if/else if/else statements... just one line, so should be ok. If you needed to add more to them, then add braces (like "if (...) {...}").

Additional thoughts: You could avoid the if/else if/if entirely and just set the framenumber to framecount, if you could deal with just having a number as that. 1, 2, 3 as the frames.
You also could EASILY adapt this to any number of frames or layout. Very easy to do that.

02-04-2007, 10:17 PM
djr33, thanks mate!! Will have a go at getting this to work and post results here shortly. Cheers again!!