PDA

View Full Version : Pop Up Script!



MrLeone
05-16-2005, 09:49 PM
Hi there!

Im looking for an pop up script that can handle several pop
ups on the same site. Can anyone post the codes here or
point me to an site with all necesarry info?

Thanks in advance

//MrLeone

jscheuer1
05-18-2005, 02:07 AM
What kind of pop-ups? For pop-up windows this Dynamic Drive script is excellent:

http://www.dynamicdrive.com/dynamicindex8/popwin.htm

MrLeone
05-18-2005, 05:48 PM
Thanks man!

Can this popup tool handle several popup windows on the same side?

Like I have 5 different pics on the same side and I want each and one of them to popup when I click on each link.

Most popup script only handle one popup on the same side.

Thanks in advance!

//MrLeone

jscheuer1
05-18-2005, 06:57 PM
On the same side of what? I've used this script to create pop-up windows for enlarged versions of several pictures on a single page. All I had to decide was if I wanted each pop-up unique or not. Since my enlarged photos were all of differing dimensions and I wanted each pop-up to conform to those dimensions, I went with unique ones. That meant using a different name for each one. Using it this way is not precisely covered in the documentation though. However, where it says:


Step 2: Insert the following code into your html document where you want the link. You can insert multiple copies of the below, depending on how many popup links you want:You can do that and change the dimensions and names for each copy to get unique windows.

spyder
05-20-2005, 03:51 AM
if you want the pop ups to be alert boxes then this works for many in a row



<SCRIPT language="JavaScript">
alert("message");
alert("message");
alert("message");
alert("message");
</SCRIPT>

cr3ative
05-20-2005, 08:31 AM
Ah, we're confusing different types of "pop ups".

The alert script produces text boxes, whereas the others produce new windows with websites in them.

cr3ative

amvmendoza
06-24-2005, 07:54 PM
Is there a script that can popup a new window once (cookie enabled) and have it pop up on a specific date and time?

Thank you.

jscheuer1
06-25-2005, 06:26 AM
Here is a script that does two out of three:

http://javascript.internet.com/cookies/only-popup-once.html

Testing for the current date and time is a fairly simple matter but, if you limit your pop-up to just one time on one date at one hour, the chances of it occurring are slim to none. Even less so if you further restrict it to the minute, let alone second of your choosing.

Anyways, here we go. For time to have any real meaning on the web it needs to be expressed in Universal Time so that it will be accurate (assuming the user's clock is set correctly, which is a big assumption) in all locations, this is the only tricky part. You can get date hour minute like so (seconds would be too restrictive and I recommend leaving out the minutes, as well):
var myDate=new Date();
var testDate=myDate.getUTCDate()+' '+myDate.getUTCMonth()+' '+myDate.getUTCHours()+' '+myDate.getUTCMinutes()+' '+myDate.getUTCFullYear()As I write this, this gives a string like so:

25 5 5 10 2005

Meaning the 25th day of Month #5, 5 hours and 10 minutes, 2005. Months are numbered starting at 0 for January. Universal Time (a 24 hour clock time) is the same difference from wherever you are that Greenwich Time is except that it never uses daylight savings time. So if usually you are 5 hours behind Greenwich, during daylight time you will only be 4 hours behind UT. Now that we have this UT string in the variable testDate all we need to do is calculate our desired date/time to UT in the same format and compare it to testDate, as test to see if the pop-up should happen. Let's say the date you want to use is May 27th 2006, 3:02pm EDT (Eastern Daylight Time). 27 will be the first number (the date), 4 will be second (the month), 11 will be the next (hours: 3+12=15(convert to 24hr notation)-4=11 convert to UT), 2 will be next (the minutes) and 2006 last (the year) giving this string to compare:

27 4 11 2 2006

So now we can use:
if(testDate=='27 4 11 2 2006')as a test to see if the pop-up should happen. Putting it all together using the above script's code for executing the pop-up which is:
function checkCount() {
var count = GetCookie('count');
if (count == null) {
count=1;
SetCookie('count', count, exp);
window.open(page, "", windowprops);

}
else {
count++;
SetCookie('count', count, exp);
}
}will give us this:
function checkCount() {
var count = GetCookie('count');
var myDate=new Date();
var testDate=myDate.getUTCDate()+' '+myDate.getUTCMonth()+' '+myDate.getUTCHours()+' '+myDate.getUTCMinutes()+' '+myDate.getUTCFullYear()

if ((count == null||testDate=='27 4 11 2 2006')&&count<20000) {
if(testDate=='27 4 11 2 2006')
window.open(page, "", windowprops);
if(testDate=='27 4 11 2 2006')
count=20000;
else
count=1;
SetCookie('count', count, exp);
}
else {
count++;
SetCookie('count', count, exp);
}
}Here's a link to a demo:

http://home.comcast.net/~jscheuer1/side/timedcookiepop_up.htm

amvmendoza
06-27-2005, 04:10 PM
Thank you for helping me out with this Popup Code.

I am trying to test it out but having problem with my PST conversions to UT hours as you have placed it within the code.


If i want to test it for today's date, and see if it pops up at 9:15 a.m. pacific standard time and 12:15 p.m. EST...how do i write the code in the Time section?

Say, i set it to 9:15a.m. my time..it will still popup after that if the users open their browsers after the time is set, correct?

Thanks for your help once again. :)

jscheuer1
06-27-2005, 05:10 PM
Ah, a left coaster. Right now aren't you on PDT? If so, you are 7 hrs behind UT. If you are truly on PST, you are 8 hrs behind UT. In each case add the number of hours you are behind UT to your time to come up with its UT equivalent. Using today's date as I type, PST and 9:15 am gives us 17:15 UT or:

27 5 17 15 2005

for the code. In my live demo, I dropped the minutes (as per my suggestion) and made the target date/time a configurable variable at the top of the script. To get that code, right click my demo page and choose 'view source'. In that case you would use:

27 5 17 2005

In both cases the pop-up will only display at the specific date/time and only once. If you want it to be all day but just one time per user, once the specific time is reached, that will require different code. I will get back to you on those modifications. That is not what I understood your original request to be.

jscheuer1
06-27-2005, 07:53 PM
Here is the new demo:

http://home.comcast.net/~jscheuer1/side/timedcookiepop_up_allday.htm