Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Refresh frames page with current frame loadout

    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

  • #2
    New Coder
    Join Date
    Apr 2005
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmm... 10 reads and no replies.

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

  • #3
    Regular Coder
    Join Date
    Feb 2005
    Posts
    400
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Last edited by Harry Armadillo; 05-30-2005 at 07:17 PM. Reason: case matters!

  • #4
    New Coder
    Join Date
    Apr 2005
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Harry Armadillo
    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

    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!
    Last edited by [m] at; 05-30-2005 at 05:51 PM.

  • #5
    Regular Coder
    Join Date
    Feb 2005
    Posts
    400
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Code:
    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.
    Last edited by Harry Armadillo; 05-30-2005 at 07:12 PM.

  • #6
    New Coder
    Join Date
    Apr 2005
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #7
    Regular Coder
    Join Date
    Feb 2005
    Posts
    400
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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/domr...doc_ref48.html
    Last edited by Harry Armadillo; 05-30-2005 at 07:16 PM.

  • #8
    New Coder
    Join Date
    Apr 2005
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Harry Armadillo
    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/domr...doc_ref48.html
    A ha! Well, this has gotten me to a point where I can handle things myself. Thanks for your help!

  • #9
    New Coder
    Join Date
    Apr 2005
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    edit:
    var appName = window.navigator.appName; is my new friend
    Last edited by [m] at; 05-30-2005 at 09:05 PM.

  • #10
    Regular Coder
    Join Date
    Feb 2005
    Posts
    400
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do believe that IE will work with:

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •