Hi!
I have a question about pop up windows.
I am making a website for adult toys store. I need to add pop up window to the site which will ask visitor to confirm their age. If they are older than 21 thay can proceed to the site. If they are not, than when click Cancel button, browser tab will automaticaly close. This is the code i have:
<!DOCTYPE html>
<html>
<head>
<script>
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==c_name)
{
return unescape(y);
}
}
}
function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
function checkCookie()
{
var username=getCookie("username");
if (username!=null && username!="")
{
}
else
{
username=prompt("By entering your name and clicking Ok you confirm that you are older than 21 years. If you are under 21 years of age you are NOT ALLOWED to enter this website. Please enter your name:","");
if (username!=null && username!="")
{
setCookie("username",username,365);
}
}
}
</script>
</head>
<body onload="checkCookie()">
</body>
</html>
This is where i found the example http://www.w3schools.com/js/tryit.asp?filename=tryjs_cookie_username .
This works great but i need to make some modifications and i am reeaally baad with javascript...
As you can see on the example link from w3schools, window is opened with basic pop up and Cancel and Ok buttons. My goal is to dimm the background more (set opacity to lets say 20%) and to close pop up window only if name is entered and Ok buton is clicked. If user clicks outside of window do nothing, if user clicks cancel close browser tab/window. Is it possible to do it with jquery so it looks nicer or to add style to this javascript window?
Thank you all for your help!
Dario