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

Javascript timer question.. 1

Status
Not open for further replies.

theAntic

Technical User
Oct 7, 2003
26
0
0
US
I'm trying to make a funtion that executes a few seconds after a page is loaded, and this function needs to execute two other functions I've already created. But since I'm new to javascripting I'm not really sure where I should even start.. I looked at the getTime() funtion, but that seems to deal with days and months more than seconds.. and that doesn't help. Is there a function, like the getTimer() function in Flash, that marks seconds?

The plan is when my first page opens it will display a logo for a few seconds, it then needs to run a function that both opens a smaller window and makes the original window itself move off screen so as not to be seen until focused on again.

I've got the window.move thing down, and that works fine both appearing and disappearing, and I've also got the function that opens and constrains the smaller window. But whenever I include those two functions in an onLoad event, either one or the other of them won't execute depending on which is second in line.. it only executes the first function before the window the blurs.

Any ideas?
 
check here: forum216


--------------------------------------------------------------------------------------------
aka.bmp
 
noooo don't let him go to JS neerds :)
LOL
poke through this:
Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>
<head>
<title>Redirect & Logout --> close frames/windowds</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<link href=&quot;/CSS/FM.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>
<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
	<!--
	function MM_openBrWindow(theURL,winName,features)  //v2.0 Dreamweaver native OpenBrowserWindow
	{
	  window.open(theURL,winName,features);
	}
	//-->
</script>
<script>
var myMinutes=1; // declare how many minutes you want allowed on the site/page
var myTime = myMinutes * 60; // convert time from minutes into seconds
var LogOut = myTime * 1000;// convert time from seconds into milliseconds
t = null;
function AutoLogOut()
{
 t = setTimeout(&quot;top.window.close()&quot;,LogOut);//  if you use frames -if no Frames use: window.close 
}
</script>
</head>

<body onLoad=&quot;AutoLogOut();&quot;>
<table width=&quot;100%&quot; height=&quot;496&quot; border=&quot;0&quot; align=&quot;left&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; bgcolor=&quot;#666666&quot; id=&quot;MAINTABLE&quot;>
  <tr> 
    <td align=&quot;center&quot; valign=&quot;middle&quot;> 
      <table width=&quot;99%&quot; height=&quot;494&quot; border=&quot;0&quot; align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; bgcolor=&quot;#FFFFFF&quot; id=&quot;INSIDETABLE&quot;>
        <tr> 
          <td width=&quot;40%&quot; height=&quot;25&quot;><hr size=&quot;1&quot; color=&quot;#666666&quot;> </td>
          <td width=&quot;20%&quot; height=&quot;25&quot; align=&quot;center&quot; class=&quot;mask&quot;> System Message</td>
          <td width=&quot;40%&quot; height=&quot;25&quot;><hr size=&quot;1&quot; color=&quot;#666666&quot;> </td>
        </tr>
        <tr> 
          <td colspan=&quot;3&quot; align=&quot;center&quot;><p class=&quot;text&quot;>You will be automatically 
              logged out in 1 minute!</p>
            <p class=&quot;text&quot;>To continue using our system please <a href=&quot;#&quot; onClick=&quot;MM_openBrWindow('Index.html','','scrollbars=yes,width=1000,height=730,top=0,left=8');top.window.close();&quot;>CLICK 
              HERE</a> and log in again!</p></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>

All the best!

> need more info?
:: don't click HERE ::
 
Ok. I think I'm getting this, but I've got some questions.

First, I've editted the timer script to include one of my functions and it seems to work. Like this:

//Timer
var myMinutes=.1; // declare how many minutes you want allowed on the site/page
var myTime = myMinutes * 60; // convert time from minutes into seconds
var LogOut = myTime * 1000;// convert time from seconds into milliseconds
t = null;
function Change()
{
t = setTimeout(&quot;Minimize()&quot;,LogOut);// if you use frames -if no Frames use: window.close
}


And now I'm interested in putting that second function in there.. but I can't get the syntax right.. Would I just add it like this?

t = setTimeout(&quot;Minimize()&quot;,&quot;openMyPopup('main.htm',490,388,'mywindow')&quot;);

It doesn't seem to work though..

www.etoddt.com​
- theAntic
 
seee it:
take it:
Code:
<script>
// found function
minflag = false; 
function Minimize() { 
window.moveTo(10000,10000); 
minflag = true; 
window.blur(); 
window.opener.focus(); 
} 
window.onfocus = new Function(&quot;if (minflag){minflag = false; window.moveTo(0,0);}&quot;); 
//Timer
var myMinutes=.1; // declare how many minutes you want allowed on the site/page
var myTime = myMinutes * 60; // convert time from minutes into seconds
var TotalTime = myTime * 1000;// convert time from seconds into milliseconds
t = null; // set the varibale 't' to 'zero'
//Pop
function POP() { //v2.0
window.open('SomePop.html','SomePop','width=400,height=400');
}
// mother function to all above
function Change(){
t = setTimeout(&quot;Minimize(POP())&quot;,TotalTime);// 
}

//-->
</script>
;-)
All the best!

> need more info?
:: don't click HERE ::
 
don't forget to call the 'mother of them all'
<body onLoad=&quot;Change();&quot;>

> need more info?
:: don't click HERE ::
 
This was VERY helpful! You gave me exactly what I needed. Thanks again!

www.etoddt.com​
- theAntic
 
Ahh!! So you imbed the pop function in the minimize function... I get it. This was EXTREMELY helpful! You gave me exactly what I needed!

www.etoddt.com​
- theAntic
 
;-)
No problem, glad it was of help.
Notice that function &quot;POP&quot;
function POP() { //v2.0
window.open('SomePop.html','SomePop','width=400,height=400');

is nothing more than the &quot;direct conversion&quot; of DW native &quot;Open Browser Window&quot; which u can apply with any &quot;decoration&quot;-scrollbars,title bar etc...
Anyhow, happy programming!
All the best!

> need more info?
:: don't click HERE ::
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top