User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 397,835 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,516 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 3584 | Replies: 3
Reply
Join Date: Jul 2006
Posts: 3
Reputation: cronos is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cronos cronos is offline Offline
Newbie Poster

Question JavaScript execution delay

  #1  
Jul 20th, 2006
Hello DaniWeb members, I've just joined up and I would like to have one of my problems solved. I'm still a begginer at JavaScript coding so my request may seem a be easy for you guys to answer so here it is:

I have a JavaScript code and I want it to have a delay of 4 seconds before starting, the code is:

[html]<SCRIPT LANGUAGE="JavaScript">
var password = ''
password=prompt('Please enter your password:','');
if (password != null) {
location.href= password + ".html";
}
</SCRIPT>[/html]

I've searched through many sites and I havn't found an answer that'll help me, so i'm hoping that you guys will. :cheesy:

Thanks - Cronos
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2006
Posts: 29
Reputation: jalarie is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
jalarie jalarie is offline Offline
Light Poster

Re: JavaScript execution delay

  #2  
Jul 20th, 2006
Put your script within a function and then use "setTimeout" to run the function:
TimeOut1=setTimeout("YourFunction()",4000);
Reply With Quote  
Join Date: Jul 2006
Posts: 3
Reputation: cronos is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cronos cronos is offline Offline
Newbie Poster

Re: JavaScript execution delay

  #3  
Jul 20th, 2006
Sorry, but could you please kindly help me place the script I have into that function? I'm very new at this, so sorry for any inconvenience.
Reply With Quote  
Join Date: Mar 2006
Posts: 29
Reputation: jalarie is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
jalarie jalarie is offline Offline
Light Poster

Re: JavaScript execution delay

  #4  
Jul 20th, 2006
The name "password" might be a reserved word, so I changed it to "pword" to avoid trouble:
<script type="text/javascript">
  function Password() {
    var password = ''
    pword=prompt('Please enter your password:','');
    if (pword == '') {
      alert('The password was null.');
    } else {
      location.href= pword + ".html";
    }
  }
  TimeOut1=setTimeout("Password()",4000);
</script>
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 7:29 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC