2 回答

TA貢獻(xiàn)1993條經(jīng)驗(yàn) 獲得超6個(gè)贊
1.src後跟圖片路徑,會(huì)直接加載。
如<img src="">,它 是標(biāo)準(zhǔn)的HTML語言 瀏覽器都能支持
2.lazy_src後跟圖片路徑,但是不會(huì)直接加載,它是延遲加載圖片路徑的JS插件,對(duì)于某些瀏覽器來說自然無法識(shí)別
延時(shí)代碼:
<script src="jquery-1.11.1.js"></script>
<script>
$(document).ready(function () {
$(window).scroll(function () {
loadImg();
})
function loadImg() {
$("img").each(function () {
if ($(this).offset().top < $(window).height() * 2 + $(window).scrollTop()) {
$(this).attr("src", $(this).attr("lazy_src")).removeAttr("lazy_src");
}
});
}
})
</script>

TA貢獻(xiàn)1826條經(jīng)驗(yàn) 獲得超6個(gè)贊
你說的 lazy_src 應(yīng)該是 圖片JS延遲加載 并非瀏覽器問題
而<img src=""> 是標(biāo)準(zhǔn)的HTML語言 瀏覽器都能支持
<script src="jquery-1.11.1.js"></script>
<script>
$(document).ready(function () {
$(window).scroll(function () {
loadImg();
})
function loadImg() {
$("img").each(function () {
if ($(this).offset().top < $(window).height() * 2 + $(window).scrollTop()) {
$(this).attr("src", $(this).attr("lazy_src")).removeAttr("lazy_src");
}
});
}
})
</script>
延時(shí)代碼
- 2 回答
- 0 關(guān)注
- 618 瀏覽
添加回答
舉報(bào)