sets an empty cookie (called “thecookie” that expires when the browser closes and is accessible via any directory on the website)
in all the browsers I have tried apart from IE7?
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
Thanks Paul, the other IE problems are not problems with the cookies though unfortunately.
Much appreciated all the same though, thanks
I will see if I can work out what’s wrong with it tomorrow.
I think in future when I write a program in JavaScript I will check both in Firefox and IE as I go, so I can fix problems as the occur rather than searching through looking for what’s wrong lol. (also writing functions to make solving cross browser problems in the future nice and easily).
You’ll find that it’s a lot easier to develop on something like Firefox and apply fixes for IE, than to do it the other way around where you develop for IE and apply fixes for Firefox.
It need not be Firefox of course, there’s also Google Chrome, Safari, Opera which are popular ones.
The issue is that there is a [http://en.wikipedia.org/wiki/Comparison_of_web_browsers vast number of web browsers] out there, so it’s best to develop from a common set of standards and then apply cross-browser techniques where required.