PDA

View Full Version : Please Help This Is Really Annoying Me


education
09-07-2005, 02:18 AM
I have a cookie that sets the colour on the homepage when you click on an option, the page turns blue then if you click a hyperlink to another part of the website that page also changes colour(Good So Far) if you then change colour on this page and return to the previous one the previous one still has its original colour how do i solve this here is my cookie script

<script type="text/javascript"><!--
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}

function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
// -->
</script>

<script type="text/javascript">
<!--
background = GetCookie('background')

if (background == "white") { document.bgColor="#FFFFFF"; }
else if (background =="silver") { document.bgColor="#F0F0F0"; }
else if (background =="skyblue") { document.bgColor="#AAD4FF"; }
else if (background =="pink") { document.bgColor="#CCCCFF"; }
else if (background =="lilac") { document.bgColor="#FFCCFF"; }
else if (background =="purple") { document.bgColor="#CC99CC"; }
else if (background =="gold") { document.bgColor="#DCB282"; }
else if (background =="green") { document.bgColor="#006666"; }
else if (background =="tan") { document.bgColor="tan"; }
else { document.bgColor = "white"; }

// -->
</script>



Thi is placed on all pages i want to have remember the colour selection

nikkiH
09-07-2005, 02:23 PM
What do you mean by "return to the previous one"? Click a link that goes back, or click the back button?
Because clicking the back button loads the cached page. It would not reset the color until the user refreshed it.