The delay script technology in javascript and the javascript delay script

Source: Internet
Author: User

The delay script technology in javascript and the javascript delay script

<Html>

<Head>

<Title> latency script technology in javascript <title>

<Script type = "text/javascript" defer = "defer" src = "some. js"> </script>

<Head>

<Body>

<! -- Content -->

</Body>

<Html>

Defer: When the script is executed, it will be delayed until the entire page is parsed and then running.


How to delay the execution of a method in javaScript?

SetTimeout () is executed only once.
If you want to call it multiple times, use setInterval () or let the code itself call setTimeout () again ().
<Html>
<Head>
<Script type = "text/javascript">
Function timedMsg (){
Var t = setTimeout ("alert ('5 seconds! ') ", 5000)
}
</Script>
</Head>
<Body>
<Form>
<Input type = "button" value = "Display timed alertbox! "OnClick =" timedMsg () ">
</Form>
<P> Click on the button above. An alert box will bedisplayed after 5 seconds. </p>
</Body>
</Html>

How can I implement operations with a delay of several seconds in javascript?

<Html>
<Head>
<Script language = "javascript">
J = 10;
Function func (){
Document. getElementById ("div1"). innerText = j;
J ++;
SetTimeout ("func ()", 1000 );
}
</Script>
</Head>
<Body onload = "func ();">
<Div id = "div1"> </div>
</Body>
It may be because I have limited understanding ability. Are you satisfied with this answer?

Can you explain what this means for (I = 1; I <10; I = 10? I = 1, I = 10

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.