불 러 올 그림

1610 단어 JavaScript
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>       </title>
<style type="text/css">
	img{background:url(loading.gif) no-repeat 50% 50%;}
</style>
</head>
<body>
<script type="text/javascript">
for(var i=0; i<60; i++){
	document.write("        <span style='color:#999;font-size:12px;'>[       ]</span><br />");
}
</script>
<p style="color:red">         </p>
<p><img data_src="http://www.ueder.net/testhtml/picshow/datapic/0e0c883622903fb1a61e12be.jpg" width="400" height="600" src="1.png" alt="" /></p>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
var itv;
$(window).scroll(function(){
    clearTimeout(itv);
    itv = setTimeout(function(){
		var winHeight = $(window).height();
		var scrolltop = $(window).scrollTop();
		var oTop = $("img").offset().top;
		if((oTop-scrolltop)>0 && (oTop-scrolltop)<winHeight){
			var src = $("img").attr("data_src");
			$("img").attr("src",src)
		}
	},500);
});
</script>
</body>
</html>

좋은 웹페이지 즐겨찾기