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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2004
    Location
    WY
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow OK i have a simple question

    Ok i have a simple JavaScript question:

    I want to create a variable on page 1 (page1.html)
    Which has a value of 66

    On the second page, i want it to keep that variable, and print it's value.

    How can i make that variable "stay" in memory?

  • #2

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Vancouver, WA
    Posts
    233
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I'm such an ignorant self-taught life-time-novice that this is the blind leading the blind, but I'll take a stab at it.

    To the best of my knowledge when you load a new page you lose everything in memory. There are two workarounds that I know of:

    1. Save the variable from page one in a cookie which is loaded by page two.
    2. Don't actually change the "page" but give that illusion by rewritting it using frames. See my recent posts on the subject.

    peterinwa

    P.S.

    Edit to the above... glenngv and I posted almost exactly the same time. Looking at his ref I didn't do so bad!
    Last edited by peterinwa; 07-16-2004 at 06:39 AM.

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Or for sessions you can pass your variable on the window.name property....

    Page One:
    <script>
    window.name = 66; // or your variable //;
    </script>

    Page Two:
    <script>
    document.write(window.name);
    </script>

    .....Willy


  •  

    Posting Permissions

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