[thelist] Carrying Javascript values over

Hassan Schroeder hassan at webtuitive.com
Fri Mar 19 07:45:49 CST 2004

The Lists wrote:

> My question is, when the user "re-load's" the page, be it submitting on 
> a form or by using a hyperlink, or just plain 'F5' is there a way to 
> carry the values set by Javascript 'over' to the newly loaded page?

If you don't mind the user seeing the values, you can put them in
the page's query string and get them from there. A very simplistic

<script type="text/javascript">
function setVars()
	// set the query string on a link with the id "a2"
         document.getElementById("a2").href += "?foo=bar";

	// set the query string on self to handle reloads
         if ( window.location.search.length == 0 )
                 window.location.search = "foo=bar";
<a id="a2" href="another.html">another page</a>

Only moderately tested, YMMV, etc., etc. OVerall, I'd probably just
use a cookie to persist such preferences, though :-)

Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.

More information about the thelist mailing list