vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How would I add a 24 hours cookie session to this script? (https://vborg.vbsupport.ru/showthread.php?t=177118)

se_p800 04-25-2008 07:13 AM

How would I add a 24 hours cookie session to this script?
 
I have this script for a popup javascript called modalbox, and the popup is only meant to popup once per day :

Quote:

<head><link rel="stylesheet" href="http://customizepsp.co.uk/forums/popup/modalbox.css" type="text/css" media="screen" />
<script type="text/javascript" src="http://customizepsp.co.uk/forums/popup/prototype.js"></script>
<script type="text/javascript" src="http://customizepsp.co.uk/forums/popup/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="http://customizepsp.co.uk/forums/popup/modalbox.js"></script>

<script type="text/javascript">
var exp = 1;
function newCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString(); }
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/"; }

function readCookie(name) {
var nameSG = name + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameSG) == 0) return c.substring(nameSG.length,c.length); }
return null; }

function Modalbox.show() {
var num = readCookie('sancookie1')
if (num < 1) {
newCookie('sancookie1','testcookie1', exp);
SW=window.open('window.html','NewWin','toolbar=no, status=no,width=350,height=135,scrollbars')
SW.moveTo(190,240); }
}
</script></head>

<body onLoad="Modalbox.show('<form action=\'http://www.gamesites200.com/psp/in.php?id=1850\' method=\'post\' target=\'_blank\' \><img src=\'http://customizepsp.co.uk/forums/popup/vote.png\' width=\'500\' height=\'72\'><table width=\'100%\' border=\'0\' cellspacing=\'0\' cellpadding=\'5\'><tr><td align=\'center\' valign=\'top\'><strong>Please reward our efforts by voting for us. </strong><br> All votes are greatly appreciated. <br><br><br> <br></td></tr><tr><td align=\'right\' valign=\'bottom\'><input type=\'submit\' value=\'Yes, I want to vote!\' onclick=\'Modalbox.hide()\' /> <input type=\'button\' value=\'No..\' onclick=\'Modalbox.hide()\' /></td></tr></table></form>', {title: this.title,width: 500});">

But, the popup still pops up every time the page is viewed. You can see the popup here, its not a typical popup: http://customizepsp.co.uk/forums/index.php?styleid=1

BUT....If I change whats in red and bold to "amt" instead of "Modalbox.show" an actual popup box appears with an error in it, but only once! So Im halfway there. I just need to know why it doesnt work with "body onLoad="Modalbox.show('.." that I have :S

Thanks

EDIT: Ok I think I have fixed this now. If you go here http://customizepsp.co.uk/forums/ and see the popup, then it doesnt appear again when ou refresh the page, then its worked! So does it work for you?


All times are GMT. The time now is 08:03 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01007 seconds
  • Memory Usage 1,718KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete