...

View Full Version : OK i have a simple question



lilmeanman
07-16-2004, 07:26 AM
Ok i have a simple JavaScript question: :cool:

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?

glenngv
07-16-2004, 07:36 AM
http://www.webxpertz.net/forums/faq.php?faq=wxfaq_1_1#faq_wxfaq_1_1_2

peterinwa
07-16-2004, 07:36 AM
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!

Willy Duitt
07-16-2004, 02:10 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum