1. Simple Chronograph window:
In this instance, we'll create a button on the page that will jump out of the warning window in 3 seconds when the button is clicked.
, please see the specific code, you can test yourself:
| The code is as follows |
Copy Code |
| JavaScript Simple Timing
<script type= "Text/javascript" > Create a function to perform a timer window function Timedmsgdemo () { Declares a variable to receive a 3-second window, where the time unit is milliseconds var timedemo=settimeout ("Alert (' 3 seconds window!") ') ", 3000) } </script> <body> <form> Create a button to trigger the event <input type= "button" value= "click the button, 3 seconds later show the window" OnClick = "Timedmsgdemo ()" > </form> <p> When you click this button, the page will jump out of the warning window in 3 seconds! </p> </body> |
2. Display the timing effect of the booking time:
In this case, we pre-set a few times, and when the page is displayed, the page will show the
Time, through this example, we have the flexibility to achieve a lot of timing effects, such as when the page more than a long time
, the page will automatically show how long the user has logged on, see the sample code below, you can expand yourself:
| The code is as follows |
Copy Code |
| Set up a few times in advance, and each time the page opens, a different text will appear on the page. <script type= "Text/javascript" > function Timedtextdemo () { Be sure to note that the time unit is the number of milliseconds var txt1=settimeout ("document.getElementById"). Value= ' You've been online for 1 minutes! Welcome to the return of the Lord To! ' ", 60000) var txt2=settimeout ("document.getElementById"). Value= ' You've been online for 10 minutes! Small, pleasant love! ' ", 600000) var txt3=settimeout ("document.getElementById"). Value= ' You've been online for 1 hours! The great masturbate to the harm, Please take care of yourself! ' ", 3600000) } </script> <body> <form> <input type= "button" value= "click on the button to display the different text" onclick= "every once in a while Timedtextdemo () "> Create a text box to display the text we want to output <input type= "text" id= "TXT" > </form> <p> in this example, when the page is open for 1 minutes, 10 minutes, and 1 hours, the text box displays no The same text </p> </body>
|
3. Simple clock effects:
This special effect is quite simple, but also is the most practical one special effect, everybody please combine two content knowledge to analyze, very simple,
The effect will be great if you extend it yourself, see the following code:
| The code is as follows |
Copy Code |
| Simple small clock effect on the page <script type= "Text/javascript" > Create a function to display the clock function Starttimedemo () { Create a new Time object var today=new Date () Declare a variable to receive the number of hours var h=today.gethours () Number of minutes received var m=today.getminutes () Number of seconds received var s=today.getseconds () M=checktimedemo (M) S=checktimedemo (s) document.getElementById (' txt '). innerhtml=h+ ":" +m+ ":" +s T=settimeout (' Starttimedemo () ', 500) } Add a 0 to the number, when the value is less than 10 function Checktimedemo (i) { if (i<10) {i= "0" + i} return I } </script> <body onload= "Starttimedemo ()" > <div id= "TXT" ></div> </body> |
OK, now to provide three examples for everyone to learn the reference, please continue to pay attention to the following!