<!--fonto:Verdana--><span style="font-family:Verdana"><!--/fonto--><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#336699--><span style="color:#336699"><!--/coloro--><br /><br />So I found a cookie script that's pretty simple which saves a user's preference for a page. Here's the JS code:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->function getCookie(NameOfCookie){<br /> Â Â if (document.cookie.length > 0) { Â Â Â Â Â Â Â <br /> Â Â begin = document.cookie.indexOf(NameOfCookie+"="); Â Â Â <br /> Â Â if (begin != -1) { Â Â Â Â Â <br /> Â Â Â begin += NameOfCookie.length+1; Â Â Â <br /> Â Â Â end = document.cookie.indexOf(";", begin);<br /> Â Â Â if (end == -1) end = document.cookie.length;<br /> Â Â Â Â return unescape(document.cookie.substring(begin, end));<br /> Â Â } <br /> Â }<br /> Â return null;<br />}<br /><br />function setCookie(NameOfCookie, value, expiredays) {<br />Â Â Â Â var ExpireDate = new Date();<br />Â Â Â Â ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));<br />Â Â Â Â document.cookie = NameOfCookie + "=" + escape(value) + <br />Â Â Â Â ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());<br />}<br /><br />function delCookie (NameOfCookie) {<br />Â Â Â Â if (getCookie(NameOfCookie)) {<br /> Â document.cookie = NameOfCookie + "=" +<br /> Â "; expires=Thu, 01-Jan-03 00:00:01 GMT";<br /> Â }<br />}<br /><br />function DoTheCookie() {<br />Â Â Â Â Preference=getCookie('Preference');<br />Â Â Â Â if (Preference!=null) {<br /> Â window.location.href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/"http://exampleaddress.com/"+Preference;<br /> Â }<br />Â Â Â Â else {<br /> Â window.location.href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/"http://exampleaddresss.com/index.html";<br />Â Â Â Â }<br />}<!--c2--></div><!--ec2--><br /><br />in the HTML page the body tags is like this:<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><body onload="preloadImages(); DoTheCookie();"><!--c2--></div><!--ec2--> the preloadImages is another function somewhere else...<br /><br />Then the html link for one page is like so:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><a href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/"#" onClick="setCookie('Preference','index2.html',365)">flash version</a><!--c2--></div><!--ec2--><br /><br />so, the cookie does save the users' preference but it keeps reloading the page incessantly instead of only once! I think its the body onLoad function, but I don't know enough!<br /><br />feel free to use the code, I found it online; it just didn't come with a lot of explanation. story of my life. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/rolleyes.gif" style="vertical-align:middle" emoid="" border="0" alt="rolleyes.gif" /> <br /><br />thanks a mil,<br />!!blue<br /><br /><!--sizec--></span><!--/sizec--><!--colorc--></span><!--/colorc--><!--fontc--></span><!--/fontc--><!--content-->
I looked at the code.<br /><br />And your right, there's nothing thre to STOP the browser from reloading the URL. It just adds on any preferences it happens to find and still reloads the page.<br /><br />You need something that checks the end of the URL, or looks for the parameters passed, before executing the reload.<br /><br />Does that make sense?<!--content-->
<!--fonto:Verdana--><span style="font-family:Verdana"><!--/fonto--><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#336699--><span style="color:#336699"><!--/coloro--><br /><br />that makes sense, but I wouldn't know how to do it <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" /> <br /><br />It's like my Spanish, I can read it but I can't write it. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/tongue.gif" style="vertical-align:middle" emoid="" border="0" alt="tongue.gif" /> <br /><br />I'll try to search for another cookie; what if I changed the html page by removing function from the body "onLoad" and did the html link like this:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><a href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/"index2.html" onClick="setCookie('Preference','index2.html',365)">flash version</a><!--c2--></div><!--ec2--><br />so the pages link AND the preference is set. but I guess that wouldn't work when the user returns on another visit (?). <br /><br />meh,<br />!!blue<br /><!--sizec--></span><!--/sizec--><!--colorc--></span><!--/colorc--><!--fontc--></span><!--/fontc--><!--content-->
I looked at the code.<br /><br />And your right, there's nothing thre to STOP the browser from reloading the URL. It just adds on any preferences it happens to find and still reloads the page.<br /><br />You need something that checks the end of the URL, or looks for the parameters passed, before executing the reload.<br /><br />Does that make sense?<!--content-->
<!--fonto:Verdana--><span style="font-family:Verdana"><!--/fonto--><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#336699--><span style="color:#336699"><!--/coloro--><br /><br />that makes sense, but I wouldn't know how to do it <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" /> <br /><br />It's like my Spanish, I can read it but I can't write it. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/tongue.gif" style="vertical-align:middle" emoid="" border="0" alt="tongue.gif" /> <br /><br />I'll try to search for another cookie; what if I changed the html page by removing function from the body "onLoad" and did the html link like this:<br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><a href=http://www.totalchoicehosting.com/forums/lofiversion/index.php/"index2.html" onClick="setCookie('Preference','index2.html',365)">flash version</a><!--c2--></div><!--ec2--><br />so the pages link AND the preference is set. but I guess that wouldn't work when the user returns on another visit (?). <br /><br />meh,<br />!!blue<br /><!--sizec--></span><!--/sizec--><!--colorc--></span><!--/colorc--><!--fontc--></span><!--/fontc--><!--content-->