1. Inverted timer: Timename=settimeout ("function ();", delaytime);
2. Cycle Timer: Timename=setinterval ("function ();", delaytime);
The first parameter "function ()" Is the action to be performed when the timer is triggered, it can be a function, or it can be several functions, separated by ";" between functions. For example, to eject two warning windows, you can "function ()". Into
"Alert (' First warning window! '); Alert (' Second warning window! '); , and the second parameter "Delaytime" is the time of the interval, in milliseconds, that is, fill in "5000", which means 5 seconds.
The countdown timer is to trigger an event at a specified time, and the loop timer is a recurring event when the time interval arrives, the difference being that the former is only a function once and the latter is constantly acting.
For example, when you open a page, want to interval a few seconds to automatically jump to another page, you need to use the inverted timer "settimeout (" function (); ", Delaytime)", and if you want to set a sentence into a word of the appearance,
You need to use the loop timer "setinterval" ("function ();", Delaytime).
Gets the focus of the form, the document.activeElement.id is used. Use if to determine whether the ID of the document.activeElement.id and form is the same.
For example: if ("mid" = document.activeElement.id) {alert ();}, "Mid" is the corresponding ID of the form.
Timer:
Used to specify a program to be executed after a certain period of time.
JS in timed execution, settimeout and setinterval differences, and L lifting method
SetTimeout (Expression,delaytime), after Delaytime, will perform a expression,settimeout application after a period of delay, and then do some action.
SetTimeout ("function", time) sets a timeout object
SetInterval (Expression,delaytime), each delaytime, will perform expression. Can often be used to refresh an expression.
SetInterval ("function", time) sets a timeout object
SetInterval for automatic repetition, settimeout will not repeat.
Cleartimeout (object) clears the SetTimeout object that has been set
Clearinterval (object) clears the SetInterval object that has been set