你的主页上有图片吗?如果没有,那么您可以先预加载图像。
在此处查看演示http://www.thewindowdr.info然后单击导航栏上的图库。
创建 image-preload.js 文件并将其粘贴,然后填写图像位置。
将此代码添加到您的标题
<script type="text/javascript" src="../js/image-preload.js"></script>
并将此代码添加到 .js 文件中
function preloader() {
if (document.images) {
var img1 = new Image();
var img2 = new Image();
var img3 = new Image();
var img4 = new Image();
var img5 = new Image();
var img6 = new Image();
var img7 = new Image();
var img8 = new Image();
var img9 = new Image();
var img10 = new Image();
var img11 = new Image();
var img12 = new Image();
var img13 = new Image();
var img14 = new Image();
var img15 = new Image();
img1.src = "../images/#####.jpg";
img2.src = "../images/#####.jpg";
img3.src = "../images/#####.jpg";
img4.src = "../images/#####.jpg";
img5.src = "../images/#####.jpg";
img6.src = "../images/#####.jpg";
img7.src = "../images/#####.jpg";
img8.src = "../images/#####.jpg";
img9.src = "../images/#####.jpg";
img10.src = "../images/#####.jpg";
img11.src = "../images/#####.jpg";
img12.src = "../images/#####.jpg";
img13.src = "../images/#####.jpg";
img14.src = "../images/#####.jpg";
img15.src = "../images/#####.jpg";
}
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(preloader);