Hi there!

I am wanting to use javascript to set a cookie which will expire on session/cookie expire and what would this cookie do? I want it to determine whether or not to show a div using a variable to set display block or none.

The div contains text "Click here to close this" which onclick will hidewelcome()

My code is as follows:

var view=getCookie("viewed");
if(view="hidden"){
var welcome = document.getElementById('dwindow');
welcome.style.display="none";
}else{
var welcome = document.getElementById('dwindow');
welcome.style.display="block";
}
function hidewelcome(){
var welcome = document.getElementById('dwindow');
welcome.style.display="none";
setCookie("hidden",viewed,12);
}

I'm not sure what I'm doing wrong and would be grateful for any help I receive.

Thanks in advance!

Public-Image

What doesn't work? How do your get and setCookie functions work?
Assuming something like function setCookie(name, value, expire) , you'll need to use setCookie('viewed', 'hidden', 12); on the end.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.