调用方式为:
<span class='lazyload' src='1.swf' type='2'>
woaini
</span>
woaini
</span>
效果就不写了,看最初的那个网址吧
<script type="text/javascript" charset="utf-8">
var threshold = 0;
$.belowthefold = function(element) {
var fold = $(window).height() + $(window).scrollTop();
return fold <= $(element).offset().top - threshold;
};
$.rightoffold = function(element) {
var fold = $(window).width() + $(window).scrollLeft();
return fold <= $(element).offset().left - threshold;
};
$.abovethetop = function(element) {
var fold = $(window).scrollTop();
return fold >= $(element).offset().top + threshold + $(element).height();
};
$.leftofbegin = function(element) {
var fold = $(window).scrollLeft();
return fold >= $(element).offset().left + threshold + $(element).width();
};
$.appear = function(element) {
if($(element).attr('class')=='lazyload' && $(element).html().indexOf('object',0)==-1)
{
var outhtml = '';
outhtml += '<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cabversion=6,0,0,0" width="60" height="60"> ';
outhtml += '<param name="movie" value="'+$(element).attr('src')+'"/> ';
outhtml += '<param name="quality" value="high"/> ';
outhtml += '<param name="bgcolor" value="#FFFFFF"/> ';
outhtml += '[>[if !IE]><<] ';
outhtml += '<object data="'+$(element).attr('src')+'" width="60" height="60" type="application/x-shockwave-flash"> ';
outhtml += '<param name="quality" value="high"/> ';
outhtml += '<param name="bgcolor" value="#FFFFFF"/> ';
outhtml += '<param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer"/> ';
outhtml += '</object> ';
outhtml += '[>><![endif]<] ';
outhtml += '</object> ';
$(element).html(outhtml);
}
};
jQuery(document).ready( function($){
elements = $("span");
$(window).scroll( function(){
elements.each(function () {
if ($.abovethetop(this) ||
$.leftofbegin(this)) {
/* Nothing. */
} else if (!$.belowthefold(this) &&
!$.rightoffold(this)) {
$.appear(this)
this.loaded = true;
var temp = $.grep(elements, function(element) {
return !element.loaded;
});
elements = $(temp);
} else {
}
});
});
$(window).trigger('scroll');
});
</script>
var threshold = 0;
$.belowthefold = function(element) {
var fold = $(window).height() + $(window).scrollTop();
return fold <= $(element).offset().top - threshold;
};
$.rightoffold = function(element) {
var fold = $(window).width() + $(window).scrollLeft();
return fold <= $(element).offset().left - threshold;
};
$.abovethetop = function(element) {
var fold = $(window).scrollTop();
return fold >= $(element).offset().top + threshold + $(element).height();
};
$.leftofbegin = function(element) {
var fold = $(window).scrollLeft();
return fold >= $(element).offset().left + threshold + $(element).width();
};
$.appear = function(element) {
if($(element).attr('class')=='lazyload' && $(element).html().indexOf('object',0)==-1)
{
var outhtml = '';
outhtml += '<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cabversion=6,0,0,0" width="60" height="60"> ';
outhtml += '<param name="movie" value="'+$(element).attr('src')+'"/> ';
outhtml += '<param name="quality" value="high"/> ';
outhtml += '<param name="bgcolor" value="#FFFFFF"/> ';
outhtml += '[>[if !IE]><<] ';
outhtml += '<object data="'+$(element).attr('src')+'" width="60" height="60" type="application/x-shockwave-flash"> ';
outhtml += '<param name="quality" value="high"/> ';
outhtml += '<param name="bgcolor" value="#FFFFFF"/> ';
outhtml += '<param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer"/> ';
outhtml += '</object> ';
outhtml += '[>><![endif]<] ';
outhtml += '</object> ';
$(element).html(outhtml);
}
};
jQuery(document).ready( function($){
elements = $("span");
$(window).scroll( function(){
elements.each(function () {
if ($.abovethetop(this) ||
$.leftofbegin(this)) {
/* Nothing. */
} else if (!$.belowthefold(this) &&
!$.rightoffold(this)) {
$.appear(this)
this.loaded = true;
var temp = $.grep(elements, function(element) {
return !element.loaded;
});
elements = $(temp);
} else {
}
});
});
$(window).trigger('scroll');
});
</script>
------------正 文 已 结 束, 感 谢 您 的 阅 读 (折雨的天空)--------------------
转载请注明本文标题和链接:《别人写的一个flash异步加载的代码》
发表评论