PDA

View Full Version : Adding cookies to this script...



sam281091
May 31st, 2007, 09:27 PM
Hello,

I have a javascript code i want to add cookies to it so it only works once per day can you help me?


<script language="javascript">

function exitask() {
if (confirm("PLEASE VOTE FOR THIS SITE SITE \n\n Thank you, come back again...")) {
vote();
} else {
window.open('blabla.htm', 'popa', 'toolbar=0, location=0, directories=0, menuBar=0, scrollbars=1, resizable=1, width=800, height=600');

}
}
function vote() {
window.open('blabla.htm', 'popd', 'toolbar=0, location=0, directories=0, menuBar=0, scrollbars=1, resizable=1, width=800, height=600');
}
</script>

And this is to load it

<body background="blabla.gif" bgproperties="fixed" OnUnLoad="exitask()">

_Aerospace_Eng_
May 31st, 2007, 10:44 PM
What have you tried? This site offers some functions for creating and reading cookies. http://www.quirksmode.org/js/cookies.html I've used the functions before and they seem to work well.

sam281091
May 31st, 2007, 11:03 PM
thanks for replying, but i just dont understand the whole factor i just need this script to function once per day is there any other simplier way or can someone do it:p

_Aerospace_Eng_
May 31st, 2007, 11:25 PM
Around here you have to show that you are actually trying to do something yourself rather than expect someone do the work for you. Here is what you have to do.

createCookie at the end of the editmask() function.

then use readCookie() to check that it exists.

if(readCookie() != null){//rest of editmask code here}