Repeated loading errors and fixes for jQuery lazyload _jquery

Source: Internet
Author: User
Analysis of the code can also be known.
The main reason is written on the page of the Once loaded, go to the server to apply for picture address, load large picture.
If you want to achieve the original effect, the address to be loaded on the page must not be the address of the large picture, and we can store the real picture address data in the ALT attribute.
The correct example is as follows:
Copy Code code as follows:

<a href= "#nogo" ></a>
<a href= "#nogo" ></a>

We also need to make a little change to the original jquery.lazyload.js:
Copy Code code as follows:

<script type= "Text/javascript" src= "Http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" ></ Script>
<script type= "Text/javascript" src= "Lazyload.js" ></script>
<script type= "Text/javascript" >//Initialization code
$ (document). Ready (function () {
$ ("#lazy1 img, #lazy2 img"). Lazyload ({
PLACEHOLDER: "Yun_qi_img/spacer.gif",
Effect: "FadeIn"
});
});
</script>

The complete example is as follows:
Copy Code code as follows:

<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title> Untitled Document </title>
<style type= "Text/css" >
img{Display:block; border:2px solid #ccc; margin:0 0 10px;}
</style>
<script type= "Text/javascript" src= "Http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" ></ Script>
<script type= "Text/javascript" src= "Lazyload.js" ></script>
<script type= "Text/javascript" >//Initialization code
$ (document). Ready (function () {
$ ("#lazy1 img, #lazy2 img"). Lazyload ({
PLACEHOLDER: "Yun_qi_img/spacer.gif",
Effect: "FadeIn"
});
});
</script>
<body>
<div style= "height:900px; width:400px; Background: #eee; " >
<a href= "#nogo" ></a>
The first screen height is 900px, when scrolling to the following, the corresponding picture began to load
</div>
<div id= "lazy1" style= "width:350px; margin-bottom:340px; " >
<a href= "#nogo" ></a >
<a href= "#nogo" >< /a>
<a href= "#nogo" >< /a>
</div>
<div id= "Lazy2" style= "width:350px;" >
<a href= "#nogo" >< /a>
<a href= "#nogo" >< /a>
<a href= "#nogo" >< /a>
<a href= "#nogo" >< /a>
<a href= "#nogo" >< /a>
<a href= "#nogo" >< /a>
</div>
</body>

Tests are known to be true on-demand loading. Rather than like before, load first, scroll to the corresponding position and then load again.
The Firebug's eyes are still discerning.
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.