Programmed pop up

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ampersand
Forum Commoner
Posts: 54
Joined: Thu Nov 28, 2002 2:00 am
Location: Norway

Programmed pop up

Post by ampersand »

How can I make a programmed pop up with a server side countdown timer that makes it pop up on a given time for every user that is surfing the site ?
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

You can't do it (as far as I can see) server-side in such a manner that the pop-up will appear every x seconds for sure. What you could do is calculate the time between a user's reloads, and if it's greater than x seconds, include the pop-up script.

That said, I hope for your users' sake that they choose mozilla or something else that blocks pop-ups.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

That's very possible.

date()

Code: Select all

<?php
if(date(insert special format here) == "12:00"){
// run
} else {
// don't run
}
?>
You'll need to include it on every page.
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

Sami, the problem is, once a webpage is loaded, it's loaded, period. This is the nature of HTTP, which is a stateless protocol, and doesn't allow the server to continue talking to the webpage once the transaction's completed. You could have the webpage refresh every X seconds, or use javascript to count the time down, but from the server, you cant force a reload.

He asked for a server-side way to do this, and it's just not possible without the cooperation of the client, so some client code is going to be necessary unless he's OK with popping up a new window if a user's refresh comes after more than X seconds.
Post Reply