Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timed Alert Windows

Status
Not open for further replies.

yumbelie

Programmer
Dec 31, 2002
96
GB
Just wondering, is it possible to have an alert window come up and then dissappear after a certain number of seconds? I ask because I want to alert users when their lease on a record is about to expire, I use <meta refresh> to redirect them elsewhere when their lease does expire, but it'd be nice to let them know without interrupting the <meta refresh> timer. As It is currently, if I flash an alert up, it pauses everything until they click OK. Any ideas?
 
use a popup window.

instead of alert use window.open to popu a window. in that window use timer events to close it after so many seconds...

Known is handfull, Unknown is worldfull
 
Something like this:

save this as &quot;Sample.js&quot;:

Code:
function Warning(Argument)
  {
    if(Argument==&quot;open&quot;)
      {
        Win_Warning = window.open('Warning.html','Win_Warning','top=50,screenY=50,left=50,width=500,height=100,scrollbars=no,scrollbar=no,menubar=no');
        setTimeout(&quot;Warning('close')&quot;,5000)
      }

    if(Argument==&quot;close&quot;)
      {
        if (Win_Warning.closed+&quot;&quot; == &quot;false&quot;)
          {
            Win_Warning.close();
          }
        else
          {
          }
      }
  }

Save this as &quot;Sample.html&quot;:

Code:
<!DOCTYPE html 
     PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
     &quot;[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>[/URL]

<html xmlns=&quot;[URL unfurl="true"]http://www.w3.org/1999/xhtml&quot;[/URL] xml:lang=&quot;en&quot; lang=&quot;en&quot;>
  <head>
    <meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;></meta>
    <title>JavaScript Sample</title>
    <script src=&quot;Sample.js&quot; type=&quot;text/javascript&quot;></script>
  </head>
  <body>
    <input type=&quot;button&quot; value=&quot;Press me to pop open the warning window.&quot; onclick=&quot;Warning('open');return false;&quot;></input>
    <br /><br />
    <input type=&quot;button&quot; value=&quot;Press me to close the warning window.&quot; onclick=&quot;Warning('close');return false;&quot;></input>
  </body>
</html>

and save this as &quot;Warning.html&quot;:

Code:
<!DOCTYPE html 
     PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
     &quot;[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>[/URL]

<html xmlns=&quot;[URL unfurl="true"]http://www.w3.org/1999/xhtml&quot;[/URL] xml:lang=&quot;en&quot; lang=&quot;en&quot;>
  <head>
    <meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;></meta>
    <title>Warning</title>
  </head>
  <body>
    <p><b>Note:</b> This process might take a few minutes to run...</p>
  </body>
</html>

Run Sample.html in your browser.

This also allows you to prematurely dismiss the warning window.

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top