Forum Moderators: open
<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.html', 'popa', 'toolbar=0, location=0, directories=0, menuBar=0, scrollbars=1, resizable=1, width=800, height=600');
}
}
function vote() {
window.open('blabla.html', '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.jpg" bgproperties="fixed" OnUnLoad="exitask()"> how can i make this so it only works once per day
// Cookie Functions
// Unknown Author - but Thanks!function getCookie( name ) {
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( (!start ) && ( name!= document.cookie.substring( 0, name.length ) ) ) {
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ';', len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}function setCookie( name, value, expires, path, domain, secure ) {
var today = new Date();
today.setTime( today.getTime() );
if ( expires ) {
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name+'='+escape( value ) +
( ( expires )? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
( ( path )? ';path=' + path : '' ) +
( ( domain )? ';domain=' + domain : '' ) +
( ( secure )? ';secure' : '' );
}function deleteCookie( name, path, domain ) {
if ( getCookie( name ) ) document.cookie = name + '=' +
( ( path )? ';path=' + path : '') +
( ( domain )? ';domain=' + domain : '' ) +
';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}
Next, we need to set a cookie to say they've voted. This setCookie function kindly works out out expiry time in a GMT string for us, so this saves us some time.
Now, add this line in your voting code, if you add it in the 'you have voted page' it'll keep bugging them all day if they don't. Otherwise, just add it in your home page.
// "askvote" is the name of the cookie
// "no" is the value
// 1 is the number of days to retain the cookie.
setCookie( "askvote", "no", 1);
Note the number of days is a 24 hour period, if you want it to forget at midnight, we can tweak it later.
Now, in your exitTask function add this line in the top...
if( getCookie( "askvote") == "no") return;
This will cancel the function if the askvote cookie has been set. I suppose you know that if they click OK they will be asked to vote, and also if they click CANCEL it'll still ask?