PDA

View Full Version : pop up only once???


Fullwebservice
03-27-2003, 07:49 PM
I want to add a pop up with news on it

But i want it so it only pop's up once a day to each person, so if they refreshed the main page they wouldnt get the pop up again


Can this be done ?


Thanks.

Jason
03-27-2003, 08:23 PM
Should be able to do this with cookies. Just specify the time to expire at midnight or something. Not really my expertise but I am pretty sure this would solve your problem.

Jason

Skyzyx
03-27-2003, 10:22 PM
This part would go in the popup window page.


<head>

<!-- Load the JavaScript library -->
<script language="javascript" type="text/javascript" src="cookies.js"></script>

<!-- Begin the script -->
<script language="javascript" type="text/javascript">
<!--
// This will set a new cookie. The name to refer to is "newsPopup".
// When it's set, it'll return true. It will last for 1 day, and be accessible to
// any page on your site (for convenience).

// This will create a cookie object.
var popupCookie = new cookie('newsPopup', true, 1, '/');

// This will set the cookie stored in the cookie object.
popupCookie.set();
//-->
</script>

</head>



This part would be inside the page that the popup window comes from.


<head>

<!-- Load the JavaScript library -->
<script language="javascript" type="text/javascript" src="cookies.js"></script>

<!-- Begin the script -->
<script language="javascript" type="text/javascript">
<!--

// Since this is a new page, we need to recreate the object.
// We will only enter the information necessary for reading the cookie.
var popupCookie = new cookie('newsPopup');

// Here, we will do an if-else statement to decide whether or not
// to show the popup window.

if (!popupCookie.read()) // If the popup has not been opened today, open it.
{
window.open(...); // Enter your own information here.
}

// If it has been opened, do nothing.

//-->
</script>

</head>


I hope this helps. I've included the cookies.js file to use for these functions. You'll have to rename cookies.txt to cookies.js.

Skyzyx
03-27-2003, 10:22 PM
.

Fullwebservice
03-28-2003, 06:14 PM
thanks alot,

:):):cool: