Both functions can be used to execute javascript code after a period of time. Both functions have two parameters. The preceding parameters are execution expressions, followed by the number of seconds. The difference is that setInterval executes code once every specified period of time, which is repetitive. However, setTimeout is called only once.
The following describes two functions through function establishment and automatic function deletion;
1. Function Creation
SetTimeOut creation:
The
PHP design pattern-share yuan pattern statement: This series of blog reference material "big talk design pattern", author Cheng Jie.
The shared object mode is used to minimize memory usage and share information with as many similar objects as possible. it is suitable for the use of a large number of objects that are unacceptable due to duplication. Some statuses of objects are usually shared. A common practice is to put them in an external data structure and pass them to the user when necessar
Statement: This series of blog reference "Big Talk design mode", author Geoscience.
Enjoy meta-mode uses shared objects to minimize memory usage and share information to as many similar objects as possible, and it is suitable for a large number of objects that are simply duplicated to use an unacceptable amount of memory. Usually part of the state in an object can be shared. It is common practice to put them in an external data structure and pass them on to the element when it is needed.
UM
When ThinkPHP calls the debugging mode, it does not know why it only displays page trace information, but does not display the page running time and database query time as TP itself said, go to brothers, QQ and ThinkPHP official website to ask questions.
When ThinkPHP calls the debugging mode, it does not know why it only displays page trace information, but does not display the page running time and database query time as TP itself said, I ran to the brothers, QQ, and ThinkPHP official website
The difference is that setinterval will be executed once every specified period of time.
Code , With repeatability. However, setTimeout is called only once.
The following describes two functions through function establishment and automatic function deletion;
1. Function Creation
SetTimeout creation:
Copy code The Code is as follows: Showtime ();
Function Showtime ()
{
VaR today = new date ();
Alert ("
Label: style blog HTTP color Io ar use for strong
Encapsulate convenient classes for parsing nsdate
This class can be parsed from nsdate year, month, date, hour, minute, second, millisecond, enough to do many things, the source code is provided as follows:
The following are core classes:
Timeinfo. h and timeinfo. m
//// Timeinfo. h // Showtime /// created by youxianming on 14-10-16. // copyright (c) 2014 youxianming. all rights reserved. // # import
) { /*Turn off RTC clock timings*/IOCTL (FD, Rtc_pie_off,0); /*turn off the RTC device*/Close (FD);}/*In case of using IOCTL, the timer function*/intRtctimer (intMillseconds,intFD) { intLoopnum =calc_cnt (millseconds); unsignedLongdata =0; for(inti =0; i ) { /*Read time = 1 seconds/clock frequency (frequency range 2~8192, minimum accuracy is 123 microseconds)*/ if(Read (FD, data,sizeof(unsignedLong)) 0) { return-1; } } return 0;}intMainintargcChar*argv[]) {
'====================================================================
' Tracespy-to write custom debug information in a record file (developer: Lin Jian)
'====================================================================
'
Property
' TraceFileName-Record file name
'
Method
' ★ Text Writing Aspect
' WriteText-Write custom text
' Clearalltext-Erase all text
' ★ Time Recording aspect
' Settimepoint-Set time start
' Gettimespanfrominit-ask for time span (distance time start)
' Gettimespanfromprev
time, only long and short two kinds ofwill take effect, immediately you define the other values, the last call or the two!
In addition toast is very common, we can take these public parts out, write in a Method!Call this method directly when you need to display a toast to show toasts, so it's much easier!Examples are as follows:
void Midtoast (String str, int showTime) {Toast toast = toast. Maketext(Global_context, str,
values are called!
In addition, Toast is very common. We can extract these public parts and write them into a method!You can call this method to display the Toast when you need to display the Toast, which is much more convenient!Example:
Void midToast (String str, int showTime) {Toast toast = Toast. makeText (global_context, str, showTime); toast. setGravity (Gravity. CENTER_VERTICAL | Gravity. CENTER_HO
Document methods:
Cyclic execution: var timeid = Window. setinterval ("method name or method", "latency ");
Window. clearinterval (timeid); stop timing: Clear the setTimeout object that has been set
Scheduled execution: var tmid = Window. setTimeout ("method name or method", "latency ");
Window. cleartimeout (tmid); stop timing: Clear the setinterval object that has been set
The setTimeout and setinterval syntaxes are the same. They all have two parameters: one is the code string to be executed,
this example, the return type is void, the parameter types are object and timeeventargs.
// Timeeventargs is a defined class used to save parameters in the event. Here we save the time, minute, and second respectively.
Public class timeeventargs: eventargs {Private int hour;Private int minute;Private int second;Public timeeventargs (INT hour, int minute, int second){This. Hour = hour;This. Minute = minute;This. Second = second;}Public int hour{Get{Return hour;}}Public int minute{Get{Return minu
.setTimeout ("code", number of milliseconds)Executes the code one time after the specified number of milliseconds.function ShowTime ()//display Time Out{var date = new Date ();document.getElementById ("hh"). InnerHTML = date;Window.settimeout ("ShowTime ()", 1000); //Plus this sentence will be repeated and not added, only once}Window.settimeout ("ShowTime ()", +)
return value Window.alert ();2. [var a =]window.confirm ("Can you run over the leopard?") "); The contents of the brackets are not meaningful, only the confirm () has a return value of true, false when judgedPrompt (); --infrequently used, no need to remember, input3. open (); Open ("Address", "_blank/_self", "new Window Features"); [var a =]window.open ("http://www.sina.com.cn"); The content inside the brackets doesn't make sense. Opens the page in a new window and returns a new window. A is
The test page must reference the jquery js file plug-in file jquery. Jwin. jsjquery. Jwin. The use parameters of the plug-in are described in the Code below:
The Code is as follows:
(Function ($ ){Var imgdir = 'images/'; // path of the image folderVar autoHide = false; // whether the suspended p is automatically hiddenVar hideType = 'hide '; // optional parameters include hide, slide, and fade.Var hideDelay = 0; // the time used by the suspension p hiding ProcessVar hideTime = 0; // The delay
! =consolekey.escape) { This. _callbackobject.run (); } }}In the main method, execute:Static int Main (string[] args) { new Controller (new callbackclass ()); Controller. Byinterface (); return 0 ; }Execution Result:
Tap any key to display the current time, ESC key to exit ...2015/08/10 16:03:222015/08/10 16:03:222015/08/10 16:03:232015/08/10 16:03:232015/08/10 16:03:23
What do you think about the use of Icallback interface variables in the controlle
If the brackets that follow the brackets contain the form parameter, the post-single-object operator is overloaded, and the invisible parameter is the pre-single-object operator.
# Include Using namespace std;
// Create a clock class
Class Clock
{
Public:
Clock (int NewH = 0, int NewM = 0, int NewS = 0); // Constructor
Void ShowTime (); // display the time function declaration
Clock operator ++ (); // overload of the prefix operator
Clock operator ++
Q: How to repeatedly display and hide divs on a regular basis
Requirement: Only DIV2 is displayed on the page. After the number of seconds, DIV3 is displayed. Manually disable DIV3 and then restart for several seconds
The interval I set is 3 seconds. The Code is as follows:
Html + css:
1:
2:
3:
4:
5:
6:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
Js:
1: window.onload =function() {
2: // obtain
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.