Add a loading to your Web page!!!!

Source: Internet
Author: User
Loading| Web pages familiar with Flash's friends know that generally larger flash works should be added loading to prevent its playback is not continuous. In contrast, the Web page is much smaller, but if the speed is very slow, open a 10KB or so of the page time to more than 30 seconds, then it is necessary to add loading.

Loading principle is very simple, add an opaque layer in the Web page, the Z-index property is set to "100", even if it is on the top level is no exception, width, height are set to "100%". The onload event is hidden when the Web page has finished loading. The specific code is as follows:
 


</title>

<meta http-equiv= "Content-type"

Content= "text/html; charset=gb2312 ">


<body >

<div id= "Loading" style= "position:absolute;width:100%; Height:100%;z-index:100;background:white; " >

<div id= "Waiting" style= "position:absolute;left:40%;top:50%;" ></div></div>

<script>

var text= "Loading document"; i=0;

function Load () {

if (i<6) {

text+= ".";

Waiting.innertext=text;

i++;}

else {text= "loading document"; i=0;}}

Timer=window.setinterval ("Load ()", 300);

</script>

<!--The following are the contents of the Web page .-->



</body>


Ok! Loading is done, try it, but it's worth noting that loading may not work when there are only <script> and <iframe> tags in the document.



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.