PDA

View Full Version : Needing an Alert box to pop up at a specific time!



Chris_S
07-15-2005, 03:25 AM
Hi:
I work at a Customer Service Center, and need to find a way to have an Alert Box state that it is thier break time, when it is thier break time! The trick is I have no access to server side, and need to know if it is possible using just HTML, Java, or whatever else.

Any Help is Greatly Appreciated!

jscheuer1
07-15-2005, 04:55 AM
Some questions:

1 ) Who will see this alert box? Will it be the Service Center Employees or the Service Center's Clients? Both?

2 ) Whoever is going to see this alert box, are they all in the same time zone?

3 ) Is it reasonable to believe that the system clocks on the computers that will be displaying this alert box are set correctly?

4 ) When should this alert box appear? As a certain page loads if it is also 'break time' or at any given time if it has become 'break time'.

Chris_S
07-15-2005, 04:09 PM
Here are the Answers!
Some questions:

1 ) Who will see this alert box? Will it be the Service Center Employees or the Service Center's Clients? Both?

A: Just my direct reports, and will be driven from our "team's website"

2 ) Whoever is going to see this alert box, are they all in the same time zone?

A: Just my direct reports, and we all are in the same building

3 ) Is it reasonable to believe that the system clocks on the computers that will be displaying this alert box are set correctly?

A: Yes, they are in sync with the companies servers.

4 ) When should this alert box appear? As a certain page loads if it is also 'break time' or at any given time if it has become 'break time'.

A: At the begginning of the day the web page is loaded by each direct report, and the Alert box will not pop up for a couple of hours until there break time starts.

I Hope this helps, and thanks for any help!

jscheuer1
07-15-2005, 10:44 PM
This should do it then, place anywhere on the page:


<script type="text/javascript">
function breakTime(){ // <<< do not edit or remove this line!
/* Set Break Hour in 24hr Notation */
var breakHour=9
/* Set Break Minute */
var breakMinute=5
/* Set Break Message */
var breakMessage="Reports! Take Your Break!"
///////////////////No Need to Edit//////////////
var theDate=new Date()
if (Math.abs(theDate.getHours())==breakHour&&Math.abs(theDate.getMinutes())==breakMinute){
this.focus();
clearInterval(breakInt)
alert(breakMessage)
}
}
var breakInt=setInterval("breakTime()",58000)
////////////////////////////////////////////////
</script>

Chris_S
07-16-2005, 01:30 AM
Thanks.....works like a charm!

I only have one last question, and you will have solved my every problem.

My reports have two breaks and a lunch, is there anyway to duplicate this to do this for a total of three alerts??

Thanks for any help you can provide!

jscheuer1
07-16-2005, 03:52 AM
<script type="text/javascript">
function breakTime(){ // <<< do not edit or remove this line!
/* Set Break Hours in 24hr Notation */
var breakHour=[9, 12, 15]
/* Set Break Minutes */
var breakMinute=[15, 0, 15]
/* Set Break Messages */
var breakMessage=["Reports! Take Your Break!", "Lunch Time!", "Afternoon Break!"]
///////////////////No Need to Edit//////////////
var theDate=new Date()
for (i = 0; i < breakHour.length; i++)
if (Math.abs(theDate.getHours())==breakHour[i]&&Math.abs(theDate.getMinutes())==breakMinute[i]){
window.focus();
clearInterval(breakInt)
alert(breakMessage[i])
if (i<breakHour.length-1)
setTimeout("breakInt=setInterval('breakTime()',58000)",120000)
}
}
var breakInt=setInterval("breakTime()",58000)
////////////////////////////////////////////////
</script>

Chris_S
07-17-2005, 02:53 AM
The only thing I notice is that the Popups are sparatic, Either they will fire late, or won't fire at all. I have had it fire the first one, and skip the last two, or will do the second one and skip the first and third, here is the small page that I put together, maybe I put something wrong, or there has to be a longer time between each popup.....any help is appreciated:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>
<HEAD>
<TITLE>Untitled</TITLE>
<META NAME="GENERATOR" CONTENT="MAX's HTML Beauty++ 2004">
</HEAD>

<BODY>
<script type="text/javascript">
function breakTime(){ // <<< do not edit or remove this line!
/* Set Break Hours in 24hr Notation */
var breakHour=[22, 22, 22]
/* Set Break Minutes */
var breakMinute=[38, 40, 42]
/* Set Break Messages */
var breakMessage=["Test", "Test1", "Test2"]
///////////////////No Need to Edit//////////////
var theDate=new Date()
for (i = 0; i < breakHour.length; i++)
if (Math.abs(theDate.getHours())==breakHour[i]&&Math.abs(theDate.getMinutes())==breakMinute[i]){
window.focus();
clearInterval(breakInt)
alert(breakMessage[i])
if (i<breakHour.length-1)
setTimeout("breakInt=setInterval('breakTime()',58000)",120000)
}
}
var breakInt=setInterval("breakTime()",58000)
////////////////////////////////////////////////
</script>


</BODY>
</HTML>



_________________________________
Thanks

jscheuer1
07-17-2005, 09:35 AM
It has to be more than 2 minutes between each pop up. With three breaks scattered throughout the workday, I figured requiring an interval of at least three minutes between breaks was reasonable. They might pop up with less than 3 minutes between them but, not likely. I wanted to be reasonably sure that the interval checking for the previous break was cleared before initializing the next. We cannot use the same interval for all three breaks because that would cause the pop up to repeat if clicked too soon - annoying. It would also prevent us from canceling the interval altogether once the last break was past. Are these pages left up all night? If so, we will need an initializing event other than the page being loaded first time in the morning.

IanMarlowe
07-17-2005, 10:58 AM
Is there a way, that if let's say some1 got in late, when they open the page, it gives thbem a pop-up: "YOU'RE LATE!"

jscheuer1
07-17-2005, 01:29 PM
Yes but, that would be pointless. They already know that they are late and no one else would see it or know about it.

Chris_S
07-19-2005, 02:09 AM
John.....My apologies to you, and yes it works like a charm, and I put that test page up to see if it would work, wasn't aware that it has to be seperated by a greater amount of time.....now you have solved all of my problems!!

Thanks

mub2
10-12-2006, 05:13 PM
Dear Professor
This realy a perfect javascript I'. looking for.
But is is possible to add to it specific date.
I have several events in:
jan 4
jan 14
feb 12
feb 16
june 16
the script you wrote works fine for several events in one day
is it possible to add to it the same events in sevral days of the year.
So I don't have to update it.
thanks

Aragoth
10-12-2006, 05:20 PM
Sorry, but if you want the best results, you should make your own thread...

Sanawman
09-27-2018, 04:04 PM
This should do it then, place anywhere on the page:


<script type="text/javascript">
function breakTime(){ // <<< do not edit or remove this line!
/* Set Break Hour in 24hr Notation */
var breakHour=9
/* Set Break Minute */
var breakMinute=5
/* Set Break Message */
var breakMessage="Reports! Take Your Break!"
///////////////////No Need to Edit//////////////
var theDate=new Date()
if (Math.abs(theDate.getHours())==breakHour&&Math.abs(theDate.getMinutes())==breakMinute){
this.focus();
clearInterval(breakInt)
alert(breakMessage)
}
}
var breakInt=setInterval("breakTime()",58000)
////////////////////////////////////////////////
</script>

I'd like to know how you can input the specific time on each breaks on the page itself if your break time changes everyday.

Sanawman
09-27-2018, 04:11 PM
How can I input the time on the webpage since my break time changes everyday?

mlegg
09-27-2018, 05:50 PM
make a brand new thread asking your question and put all of the details there. this is a 13 year old thread