Hello everyone,
Just wondering how I should go about changing some a paragraph of text from ‘hello new user’ to ‘hello n00b’ if the user hasnt been to my site before.
so far I’ve been fooling around with this JS:
function bakeCookie(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 salivateAfterCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca*;
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 eatCookie(name) {
bakeCookie(name,"",-1);
}
window.onload = function() {
blah = document.getElementById('begin');
if(salivateAfterCookie('visitor') == 'old') {
document.write('hello again')
} else {
document.write('hello n00b')
}
bakeCookie('visitor', 'old', 999)
}
but, when i visit the page, only the ‘hello again’/‘hello n00b’ text displays, and the rest of the site doesnt.
also, how can i get it to write into one specific div?
or shoudl i do all this in .php?
thanks