SetTimeout JS final loading

Source: Internet
Author: User

First JS delayed Loading
Copy codeThe Code is as follows:
<Script language = "JavaScript" src = "" id = "my"> </script>
<Script>
SetTimeout ("document. getElementById ('My '). src = 'include/common. php';", 3000); // delay of 3 seconds
</Script>

Generally, setTimeout is used for implementation.
Final loading of second JS
Insert the following code where Javascript is to be inserted:
Copy codeThe Code is as follows:
<SPAN id = L4EVER> LOADING... </SPAN>

Of course, the LOADING... You can change to a small image you like. It looks very AJAX.
Insert at the bottom of the page:
Copy codeThe Code is as follows:
<SPAN class = spanclass id = AD_L4EVER> <script src = "1.js"> </script> </SPAN>

Js Code
Copy codeThe Code is as follows:
<Script> L4EVER. innerHTML = AD_L4EVER.innerHTML; AD_L4EVER.innerHTML = ""; </script>


The standard syntax of setTimeout is: setTimeout (expression, time (MS.

Note the call of the first parameter as a function. Assume It is a function.

1. The function has no parameters:
Function alertV () {alert ("000 ");}

When the first parameter is not enclosed by quotation marks ("" or ''), the delay is one second:
SetTimeout (alertV, 1000 );

When the first parameter is enclosed by quotation marks, the delay is one second:
SetTimeout ("alertvs ()", 1000 );


2. function parameters:

Function alertV (event) {alert ("keyCode =" + event. keyCode );}

Set this parameter:
SetTimeout (function () {alertV (event) ;}, 1000); otherwise, the system will prompt that the parameter is not defined.

If anyone has a good method, thank you for sharing it.

Related Article

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.