javascript timer

javascript timer

At javascritp, there are two special about timer function, they are:

1. Counting down the number of seconds timer : timename = setTimeout ( "function ();", delaytime);

2. Cycle timer: timename = setInterval ( "function ();", delaytime);

function () is a timer to trigger the implementation of the case are a function of, can be a function, it may also be some function, or javascript statements can also be a single use; separated; delaytime is the time interval in order to milliseconds.

Countdown timer is triggered after a specified time case, and the cycle timer is at repeated intervals when the arrival of trigger events, the difference is: the role of the former only once, while the latter the role of non-stop.

Countdown timer on the page is generally used only once required to trigger the situation, such as clicking a button at a certain time after the page Jump to the corresponding sites, can also be used to determine whether a viewer you are not on the site of the "old off ", if not, you can be at 5 or 10 seconds after the second Jump to the corresponding site, and then later told him in a certain place by a certain button to enter the Express.

Cycle timer generally required for the site on the results of their implementation from the complex, such as a javascript scroll bar or status bar can also be used to page the background of the picture with snow to express. These events from time to time required to run first.

Sometimes we also want to remove some of the timer to add at this time can be used clearTimeout (timename) to turn off the countdown timer, and use clearInterval (timename) to turn off the cycle timer.

Example 1:
<SCRIPT LANGUAGE="JavaScript ">
setTimeout ( "confirm ('123456 ')", 1000);
</ SCRIPT>

<script language="JavaScript "type="text/javascript ">

function count () (
setTimeout ( "alert ( 'three seconds to the')", 3000)
)

</ Script>

Sometimes, we want to remove a timer, like the cycle timer is always kept the sport. Can be used clearTimeout (timename) to remove the setTimeout () timer, and setInterval () is used clearInterval (timename) to remove.

clearInterval (): terminate the timer. clearInterval (timer object name)

分类:AJAX 时间:2009-04-11 人气:1022
分享到:
blog comments powered by Disqus

相关文章

  • [Transfer] with Google Reader imitation load the page scrolling effect of the scroll bar 2010-11-12

    Google Reader has a AJAX scollLoad effect is very good, that is, items do not need to read the page, the browser scroll bars automatically when a certain position pulled down load the new batch of projects come in, load all items have been completed

  • iframe within the page without frame without the scroll bar code 2008-06-05

    <iframe src="http://www.xland.com.cn" width="750" height="30" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes"&

  • Get page size using Javascript. Window size and scroll bar position 2010-03-09

    Page size, window size and scroll bar position of these three values in different browsers such as Firefox and IE has a different implementation. Even in the same browser, such as IE, there are different versions of different implementations. In this

  • [Change] HTML form, click on the link, the prohibition of page jump to the top of the solution 2010-08-30

    Recently developed a small web of a button when you want to add a pop-up dialog feature, but found that after clicking the button always automatically scroll to the top of the page, this speaking from the user experience is extremely uncomfortable, a

  • flash dynamic text scroll bar 2010-04-04

    ★ last wrote a scroll of the dynamic text based on the scroll bar, but in fact that is mainly to find a solution to a major BUG in the way, but no idea that they were much better as a tutorial site reproduced, was very disturbing, today dedicated the

  • Page scroll bar handle 2010-04-15

    GOOGLE to some useful information: [DIV + CSS] XHTML issues under the scroll bar 1.xhtml under the color of the scroll bar problem? In the original html, we can define the whole page scroll bar body ( scrollbar-3dlight-color: # D4D0C8; / *- -* the ou

  • Page script and verify the page's input text box 2010-05-13

    <% @ Page contentType = "text / html; charset = UTF-8"%> <% @ Include file = "/ common / taglibs.jsp"%> <a href="javascript:jumpPage(1)"> Home </ a> <s:if test="%{#request.page.pageNo> 1) &q

  • A common JavaScript page 2009-02-27

    1.JavaScript code Pagination=function(id) { var totalNum=0; var maxNum=10; var pageUrl=""; var breakpage = 5; var currentposition = 0; var breakspace = 2; var maxspace = 4; var currentpage=1; var perpage=10; var id =id; this.initPage = function(

  • static javascript page value of three methods 2009-08-24

    static javascript page of the three methods of value 2008-06-08 10:31 A: JavaScript delivery of static pages URL value can have URL for articles by value. To take the message to the URL on. Post.htm Copy the contents to the clipboard code: <input typ

  • To obtain the page size using Javascript. Window size and position of scroll bars 2009-02-16

    Page size, window size and scroll bars position of these three values in different browsers such as Firefox and IE, have different implementations. Even in the same IE browser, for example, different versions have different implementations. In this p

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.248 (s). 15 q(s)