2 回答

TA貢獻1993條經驗 獲得超6個贊
1.src後跟圖片路徑,會直接加載。
如<img src="">,它 是標準的HTML語言 瀏覽器都能支持
2.lazy_src後跟圖片路徑,但是不會直接加載,它是延遲加載圖片路徑的JS插件,對于某些瀏覽器來說自然無法識別
延時代碼:
<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貢獻1826條經驗 獲得超6個贊
你說的 lazy_src 應該是 圖片JS延遲加載 并非瀏覽器問題
而<img src=""> 是標準的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>
延時代碼
- 2 回答
- 0 關注
- 622 瀏覽
添加回答
舉報