...

View Full Version : Refresh frames page with current frame loadout



[m] at
05-30-2005, 02:10 PM
I'm trying to do a site with different skins. The skins are basically just CSS files pointing to different images and such. Anyhow, the frame happens to use iFrames, which is making the skin swapper a real pain in the butt. I want users to be able to change skins on the fly, but when they hit the skin change button (which directs them to index.php?skin=xx) they lose their current frame loadout and find themselves back at the home page. Is there a way to use javascript to get the current loadout, pass it on to the index page, and then reload the frames (with the new skin of course)?

I tried using document.GetElementById("frame"). src but it kept returning the source allotted to it by the index page, even after it had changed. I'm really new at javascript, so maybe there's a better way to do this.

Thanks :thumbsup:

[m] at
05-30-2005, 04:21 PM
hmm... 10 reads and no replies.

parent.frameName also contains no attributes, so it's a no-go there as well.

Harry Armadillo
05-30-2005, 04:29 PM
document.getElementById("frame").contentDocument.location

And instead of having javascript reload the appropriate iframe contents, have your php send the page with the proper frame src.

index.php?skin=xx&frame=yy

[m] at
05-30-2005, 04:37 PM
document.GetElementById("frame").contentDocument.location

And instead of having javascript reload the appropriate iframe contents, have your php send the page with the proper frame src.

index.php?skin=xx&frame=yy

Thanks. How can I tell php what the frame src is? Are you saying I should use get variables to determine frame sources?

<a href="index.php?skin=xx&frame1=yy&frame2=zz" target="_TOP">link</a>
as opposed to <a href="menu1.php" target="menu">link</a>

and <iframe src="<? $HTTP_GET_VARS['frame1']">?

This could indeed work...

Also, is there some sort of central Javascript website to find out how to use functions and modifiers like the one you just posted? I'm having a hard time learning JavaScript simply because of the apparent lack of resources.

Thanks again :D

edit: i just realized that this probably wouldn't work because many of the frame urls themselves have to be passed get variables, and so i'd end up with something like this:

index.php?skin=xx&frame1=menu.php?type=pkg&id=4&frame2=content.php?id=5

which would cause all kinds of problems!

Harry Armadillo
05-30-2005, 04:51 PM
No central source that I know of, but lots of good resources listed in the documentation sticky.

For your link, you'll want to do something like

<a href="index.php?skin=xx" onclick="addFrameInfo(this)" target="_TOP">link</a>

And then have a function along the lines of

function addFrameInfo(lnk){
var f1=top.document.getElementById("frame").contentDocument.location //maybe chop the URL down the to important parts
var f2=...
lnk.href+="&frame1="+f1+"&frame2="+f2;
}That way your link would update its href as it's clicked, and wouldn't have any old/invalid data for the javascript-impaired.

Edit: Even the frame URLs that use query strings can be dealt with. Use the javascript function escape(...) to encode the strings.

[m] at
05-30-2005, 06:07 PM
Using regular brackets on document.GetElementById had mozilla reporting that it was a function. I switched it over to using square brackets, and now it's telling me that document.GetElementById has no properties. I guess this error is preventing the function from functioning because the additional GET vars aren't being passed on.

I find it strange that it would say that that my iFrames have no properties when in reality they have many properties. Darn this javascript!

Harry Armadillo
05-30-2005, 06:14 PM
Ahh shoot -- typo! Sorry about that. :(

It's getElementById with a lower-case 'g'. And, yes, it's a function (when typed right).

http://www.mozilla.org/docs/dom/domref/dom_doc_ref48.html

[m] at
05-30-2005, 06:31 PM
Ahh shoot -- typo! Sorry about that. :(

It's getElementById with a lower-case 'g'. And, yes, it's a function (when typed right).

http://www.mozilla.org/docs/dom/domref/dom_doc_ref48.html

A ha! Well, this has gotten me to a point where I can handle things myself. Thanks for your help! :thumbsup:

[m] at
05-30-2005, 07:54 PM
Aaaaaaaaaaggggggh!

So I've gotten everything to work more or less... IN FIREFOX. Once again, Internet Explorer makes my life a living hell by giving me this error:

'document.getElementById(...).contentDocument.location' is null or not an object

Now, Internet Explorer is the reason I'm using frames in the first place, as it wasn't properly handling the CSS required to lay the page out with divs only. Why is it that everything that works perfectly in Mozilla Firefox crashes and burns in Internet Explorer? Why do people still use this browser? Anyhow, does anyone know some sort of workaround that I can use? Maybe a different way to get the frame's source that Internet Explorer will recognize?

How about a piece of Javascript that will download and install Firefox on to the user's computer while it deletes Internet Explorer? Now THAT would be handy. :mad: :mad: :mad:

edit:
var appName = window.navigator.appName; is my new friend

Harry Armadillo
05-31-2005, 01:53 AM
I do believe that IE will work with:

document.getElementById(...).contentWindow.location



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum