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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close a page using a timer ? 3

Status
Not open for further replies.
Apr 25, 2002
156
GB
Hi All,

I have a relatively simple problem i hope.

I am displaying a unathorised User page for our intranet and i wish to display a countdown timer or a message to inform the user of the amount of seconds left before the page is closed and then i also want to close the active window and return to the start page of our intranet .....

thanks in advance

murray
 
use javascript,
this is jsut an example:
Code:
<script>
TimeAvailable=10 //seconds
timer=setInterval("countdown()",1000)
function countdown()
{
 TimeAvailable--
 status=TimeAvailable //Remaining time available will be shown in the status bar...
 if(TimeAvailable==0)
 {
  window.close()
 }
}
</script>

Known is handfull, Unknown is worldfull
 
Hi,

Thanks for the quick response i gather i am using it like this ? or do i have to tell it what script to run ?

here is where i have placed it ....

<html>
<head>
<title>Unauthorised Access</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body bgcolor="#FFFFFF" text="#000000">

<table width="518" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center">
<h1>Unauthorised Access</h1>
</td>
</tr>
</table>
<div align="center">
<h3><br>
<br>
Sorry, you are not authorised to enter the secure area of our intranet.</h3>
<p><br>
If you try again make sure check that your login details are correct.<br>
</p>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" startspan U-File="_private/form_results.txt"
S-Format="TEXT/CSV" S-Label-Fields="TRUE" --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--webbot
bot="SaveResults" endspan -->
<p><input type="button" value="Back to Intranet Start Page" name="B3" onclick="self.close()"></p>

<%
<script>
TimeAvailable=10 //seconds
timer=setInterval("countdown()",1000)
function countdown()
{
TimeAvailable--
status=TimeAvailable //Remaining time available will be shown in the status bar...
if(TimeAvailable==0)
{
window.close()
}
}
</script>
%>


</form>
<p>&nbsp;
</p>
</div>
</body>
</html>

regards
Murray
 
lose the asp delimiters '<%' first

and put the script between the </head> and <body> tags. It will then start as the page loads.

bear in mind that users may see a warning box about a script trying to close the page.



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems
 
Hi Again

Once again the wonderful people at tektips have came to my rescue and it works

regards

Murray
 
Hi again

I now have this working but as i am new to all of this how do i get the number that is displaying in the status bar to read in a message box or as a line of text to display on the page in html.... ?

I want it to be a timer and like it is displaying in the status bar display it in text

regards

Murray
 
u have to use DOM..
istead of this:
status=TimeAvailable
give this:
document.getElementById('status').innerText=TimeAvailable



now add his code to ur HTML:

</form>
<p>&nbsp;
<div id='status'></div>
</p>
</div>




Known is handfull, Unknown is worldfull
 
rdrunner40,

One quick note, if you'd like the page to close w/o the user being prompted the message, do this:
Code:
<script>
TimeAvailable=10 //seconds
timer=setInterval("countdown()",1000)
function countdown() {
   TimeAvailable--
   status=TimeAvailable //Remaining time available will be shown in the status bar...
   if(TimeAvailable==0) {
      top.opener = self;
      top.window.close();
   }
}
</script>

-kaht

banghead.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top