Defining action on window load
Posted
by zac
on Stack Overflow
See other posts from Stack Overflow
or by zac
Published on 2010-05-05T16:35:00Z
Indexed on
2010/05/05
16:38 UTC
Read the original article
Hit count: 164
JavaScript
I am trying to get a page to display specific properties depending on whether or not a specific cookie is set... I am trying this
var x = readCookie('age');
window.onload=function(){
if (x='null') {
document.getElementById('wtf').innerHTML = "";
};
if (x='over13') {
document.getElementById('wtf').innerHTML = "";
};
if (x='not13') {
document.getElementById('emailBox').innerHTML = "<style type=\"text/css\">.formError {display:none}</style><p>Good Bye</p><p>You must be 13 years of age to sign up.</p>";
};
}
It always just defaults to whatever is in the first if statement... I am still learning my javaScript so I am sure this is sloppy.. can someone please help me get this working?
© Stack Overflow or respective owner