Hi there,
Is there a way to close a javascript popup after a few seconds delay and return focus back to the underlined form?
I am using setTimeout(‘variablename’, 2000), but am having no success.
David
Hi there,
Is there a way to close a javascript popup after a few seconds delay and return focus back to the underlined form?
I am using setTimeout(‘variablename’, 2000), but am having no success.
David
Subject: Close a javascript popup
David,
Here’s ONE way to do it – I’ll give you this way because you may find it useful for other things…
Assuming you are using Notes Forms for your popup (you’ll obviously have to change things if this is not the case)
In your popup’s JS Header:
var secs
var timerID = null
var timerRunning = false
var delay = 1000
function InitializeTimer()
{
// Set the length of the timer, in seconds
secs = 9
StopTheClock()
StartTheTimer()
}
function StopTheClock()
{
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}
function StartTheTimer()
{
if (secs==0)
{
StopTheClock()
window.close() // This is where the popup closes
}
else
{
self.status = secs
secs = secs - 1
timerRunning = true
timerID = self.setTimeout("StartTheTimer()", delay)
}
}
In your popup’s onLoad event:
// A JS Timer – can be used for just about anything…
InitializeTimer()
Hope this helps!
Gary
Subject: RE: Close a javascript popup
Gary,
Thanks for the response. I am sorry I actually meant closing an alert/confirm prompt. I understand the window concept and using the window.close, however, my issue is with a prompt. More specifically, I am working on a timer issue and whenever my confirm displays, my timer stops.
David
Subject: RE: Close a javascript popup
No. You can close a browser window you open, but not a system modal box (alert(), prompt() or confirm()).
Subject: RE: Close a javascript popup
Stan,
Thanks. Any ideas as to how I could keep my timer running? Because whenever my confirm is displayed, the timer stops and resumes only after clicking ok.
David
Subject: I think that depends on the browser
I think IE stops everything whilst a confirm box is displaying, but FireFox doesn’t
Build you own fake confirm dialog using a layer.
Example of the kind of thing you could do here: http://www.wingo.com/dialogbox/index.html
Lots of others out there, google can find them