将具有style =“display:none”的图像仍然是下载和缓存? [英] Will an image with style="display: none" still be downloaded and cached?

查看:113
本文介绍了将具有style =“display:none”的图像仍然是下载和缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找出一种方法来缓存我的画廊脚本中的下一张和以前的图片...我想知道这是否是一个好的方法。

I'm trying to figure out a way to cache the next and previous images in my gallery script ... I'm wondering if this is a good way to do it. Also, is there any way to manually specify the cache time for the downloaded image?

推荐答案

显示: none 图像将在客户端上下载并缓存。但是,JavaScript已经有一个明确定义的预加载图像的方式:

display: none images will be downloaded and cached on the client. However, JavaScript already has a well-defined way of preloading images:

  var nextImage = new Image();
  nextImage.src = "your-url/newImage.gif";

这会预先加载图片,而不会显示给用户。

This will preload an image without displaying it to the user.

这篇关于将具有style =“display:none”的图像仍然是下载和缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆