View Full Version : javascript to check for paticular frameset then load different frameset

12-18-2006, 01:45 AM
Okay...here is my predicament...

I have a client that wanted an HTML (actually it's PHP CMS) site but wanted music to play (an mp3 jukebox). So I created a site with a left frame that appears to be a part of the main site, to hold the jukebox.

Now...they also wanted to be able to change the template of the CMS and have three different choices for the end user to select the design of the site. The CMS has the template chooser built in so that is taken care of.

The problem arises when the end user changes the template, the left frame no longer matches the site.

So...I am looking for some JavaScript to put in the head of each template that checks to see which frameset is currently loaded in the browser and if it is not the frameset that matches the particular template, the browser will refresh to the correct frameset. There will be three framesets/templates (i.e. one yellow, one blue, one green) all together, so I am guessing that the JavaScript will have to have some if/else if (s) in it.

If anyone has any idea how to make this happen could you please post the code here with a short explanation

Thank you VERY much for your time and help :) .

12-18-2006, 03:45 AM
Are you saying that you have one frameset loaded into the right frame and based upon which that is, you want the left frame's source to change?

In other words, is it like so:

top page - a frameset with left and right frames.

right frame of top page - has a frameset loaded into it.

left frame of the top page - has an mp3 player loaded into it.


12-18-2006, 04:19 AM
Yes that is correct...sort of.

There is a frameset index.htm that loads the left frame, music.html that is yellow and the right frame, index.php from the CMS that is yellow. From a page in the main frame, the user chooses to change the main frame to a new template that is lets say blue. I am looking for JavaScript that is in the blue main frame page to change the source of the music frame to blue IF the blue template is in the main frame. IF the green main frame template is is chosen and loaded, then JavaScript in the green main frame would change to the left music frame to the green mp3 player page. IF the yellow main frame template is loaded, then the music frame would change/refresh to the yellow mp3 player page. Make since?

12-18-2006, 07:38 AM
I'm still not entirely clear on this setup but, we're getting there. What I want to know is, when the template changes, is it a different filename or just a different include or different style?

If it is a different file, you could have as a part of its onload event a function that changes the music page or even, just a few key elements of the music page's style.

I'm wondering too if the template can be changed at any time or only while one is on the main page of a given template. If it can be changed at any time, each page in each template would need code to change the music page. Since you probably don't want the music interrupted just for a template change, changing the music page's style would be the better approach.

I think I would have better luck coming up with a solution if I had a link to your pages.

Anyways, what I am currently leaning toward is modifying this script:


to make it change the style of the music page and having that key off of the template changes in some way that would be best known to me if I could see the CMS in operation.

12-18-2006, 07:05 PM
Thanks again. Its a Joomla CMS that has a template chooser module that selects a new template file with it's own file/images folder/css. The content stays the same. Since it is a pre installed module that chooses the template file to use, I am assuming that any scripting would have to go in the seperate template files head and not in the template chooser/changer itself.

When you go to the site you get the frameset index.htm. That frameset has a left frame (the music frame) and a content frame (the index.php of the CMS) that builds the content pages from an MySQL database. All the CMS pages are displayed inside the content frame.

You can view at http://www.2bce.com . Go to the 'Play' page to change the template.

12-18-2006, 07:32 PM
I'm not sure how but, unless you've already added some javascript to this, Joomla should be able to take care of that. It already is to a degree, so you only need to widen the scope of what it is doing. This would be the best method.

To see what I am talking about, use the FF browser, go to the play page, change to blue. Then right click on the main frame, choose:

This Frame > Show Only This Frame

It will register that the frameset is missing and reload it with the music frame now blue! But, the index.php that is showing will now be yellow. If you then go to the play page again though, it will be blue and if you go home again it will be blue. Go anywhere, its blue.

Reversing the process is even smoother (going from blue to yellow) as yellow is the default.

The fact that this happens at all shows that Joomla should be able to handle it.

I'd ask in a Joomla forum as, getting the CMS you are already using to handle this will be much better in the long run.

Added later - the Joomla isn't loading different pages for the main section. It is loading the same pages with different style. This is all the more reason to use Joomla to do this.

12-19-2006, 01:31 AM
Thanks John, I'll check with the Joomla community so see how to go about this. Thanks for all you help!!!