View Single Post
  #1  
Old 04-25-2008, 07:13 AM
se_p800 se_p800 is offline
 
Join Date: Oct 2007
Posts: 102
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01199 seconds
  • Memory Usage 1,770KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete