"Tom Szabo" <to*@intersoft.net.au> wrote in message news:<41********@dnews.tpgi.com.au>...
Hi,
In order to preserve some settings and avoid cookies I have thought of the
following trick:
I simply create an array as the property of the window:
window.aList = new Array();
and add the values to be preserved for after refresh.
While I can add the values fine, once I refresh the page the array is reset,
or at least it appears to be!
Any idea how cen I preserve the property of the the window????
TIA,
Tom
Tom: thanks for a good laugh.
In order to preserve some settings and avoid cookies I have thought of the
following trick:
[snip]
While I can add the values fine, once I refresh the page the array is reset,
or at least it appears to be!
Something in re carts, horses, etc. springs to mind.
Although the window object represents the browser window
(application), it also serves as the global object - actually pointing
to the real one - for all scripting running in a given document. To
avoid chaos and security nightmares the sandbox is cleared when a new
document is loaded - and, naturally, window properties go with it. The
exceptions are few; the only one reliable enough for what you want is
the window.name property. This is used for HTML targeting, so it must
persist across documents or be useless. It can hold strings of (iirc)
256 characters, limited to alpha/underscore...believe IE is more
flexible there. It is a nice space for storing small bits of data,
carefully. I've serialized string arrays using Array.join() for
storage, as an example.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www/w3/org/TR/xhtml1">
<head>
<title>untitled</title>
<script type="text/javascript">
//<![CDATA[
if (self.name.search('_DATA_') == -1)
self.name = '_DATA_This|is|some|more|string|data...';
else self.name = self.name.replace(/more/, 'more|more');
// ]]>
</script>
</head>
<body>
<pre>
<script type="text/javascript">
//<![CDATA[
if (self.name.search('_DATA_') != -1)
{
data = self.name.replace(/_DATA_/, '').replace(/\|/g, '\n');
document.write(data);
}
setTimeout('top.location.reload()', 3000);
// ]]>
</script>
</pre>
</body>
</html>