使用JQuery或Javascript预加载网站上的所有图像 [英] Preload all images on a website with JQuery or Javascript
问题描述
目前我似乎无法在此找到任何可靠的代码,但我想知道(如果可能的话)如何使用JavaScript或JQuery预先加载网页上的所有图像。
I can't seem to find any solid code on this at the moment, but I wanted to know (if possible) how to have all the images on a webpage preloaded using JavaScript or JQuery, for example.
在将图像预加载到网站时,可能会显示预加载屏幕或叠加层,然后在完成后淡出或消失。对此的任何帮助/指示都会很棒!
Maybe have a pre-loading screen or overlay that displays while the images are being preloaded to the site, then fades out or disappears when done. Any help/direction on this would be amazing!
谢谢!
推荐答案
您可以在加载页面时显示启动画面或加载屏幕,然后在JQuery告诉您页面已完全加载时删除此屏幕。这样的事情:
You could display a splash screen or a loading screen while the page is loading, and then remove this screen when JQuery tells you the page has been fully loaded. Something like this:
$(document).ready(function() {
// add loader
});
$(window).load(function() {
// remove loader
});
这篇关于使用JQuery或Javascript预加载网站上的所有图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!