ma********@gmai l.com wrote:
<snip>
The objective here is simply to keep a
reference to an object that stays when the page is reloaded.
I figured the obvious place to assign such a reference would be in the
navigator object. Something like:
alert('before assignment: ' + navigator.stuff );
navigator.stuff = 5;
alert('after assignment: ' + navigator.stuff );
That aint really gonna get it.
You have to keep in mind where the code is actually running
that sets the value , in relation to where the code is actually running
that reads the variable.
lets say I had a frameset something like
<frames>
<frame rows ="50%,50%,*" >
<frame src="pageA.html " name="pageA">
<frame src="pageB.html " name="pageB">
<frame src="blank.html " name="secretfra me">
</frameset>
</frames>
Now as you can see
we have pageA.html that takes up 50% of the screen
we have pageB.html that takes up 50% of the screen
and we have blank.html that takes up the remainder (*) which in this
case is nothing (at least nothing visible)
So from any of these frames I could store values in either the
"top" which is the document holding the three frames, as in
top.stuff=5. If the top frame holding your framest was itself in frames
then that containing frame would become "top", but for pageA,pageB and
secret, there is another name called "parent" which always referes to
the the immeadiately containing frame. I prefere using parent
as opposed to top, as it works no matter how much nesting occurs
Now if pageA ,pageB, or Secret are reloaded the values in top.stuff
or parent.stuff (same thing in your case) will remain, which you can
test with script in any of those pages by setting and getting top.stuff
from any of those frames
you can also reach from pageA to PageB or secret with
parent.pageA.st uff=parent.page B.stuff or parent.pageA.st uff ="foo"
Now if the user reloads the entire framset , your sand castle will
be blown away (variables page and all)
To servive this , there is a place in every document called
document.cookie
The cookie does exactly what you want , in that it will hold a value
in the users browser for hours , days ,months etc , and as soon
as that browser comes back to your page, the document.cookie
will still have that value.
Searching arround will find you some cookie code , or you can snag it
with my DHTML kit in the DHTML section of my site. cokkies
are not exactly as simple as document.cookie ="foo" and require a little
formatting , but even if the user closes their browser , shuts down
their computer, that value will still be their when the boot up and
visit your site.
--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML, CSS,Javascript
--=<>
http://resume.drclue.net <>=-- AJAX, SOAP, XML, HTTP
--=<>
http://www.drclue.net <>=-- SERVLETS,TCP/IP, SQL
--.