预加载图像不适用于非缓存图像 [英] preload image does't with non cached images

查看:75
本文介绍了预加载图像不适用于非缓存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个预先加载图像并显示缩略图的文字脚本。一旦

你就可以看到真实大小的图片


它在正常情况下会很糟糕但是当网址有一些参数时
$ b样本中的$ b。每次我查看

缩略图时都会再次加载图片。

是否只有一个加载havint的解决方案?

函数AddImage( url){

document.write("< a href = \" javascript :; \"

onMouseOver = \document.myImg.src =''" + url +"''; \">< img src = \"" + url +

" \" width = \" 80 \" height = \" 80 \" border = \" 1 \">< / a>");

}


我这样称呼


AddImage('http://www.wettercam24。 ch / cgi-local / archiv / eggishorn / webcam.cgi?func = bild'');< / script>

Here is a litle script that preload images and show a thumbnail. Once
you get on the picture you see the real size

It worsk fine with normal picture but when the url has some parameters
like in the sample. The image is loaded again every time I go over the
thumbnail.
Is there a solution for havint just one load?
function AddImage(url) {
document.write("<a href=\"javascript:;\"
onMouseOver=\"document.myImg.src=''" + url + "'';\"><img src=\"" + url +
"\" width=\"80\" height=\"80\" border=\"1\"></a>");
}

that i call like this

AddImage(''http://www.wettercam24.ch/cgi-local/archiv/eggishorn/webcam.cgi?func=bild'');</script>

推荐答案

Michel hu kiteb :
Michel hu kiteb:
这是一个预装图像并显示缩略图的小文件。一旦你得到了图片,你就会看到它的真实大小

它在正常情况下会很糟糕,但是当网址中有一些参数时,就像在样本中一样。每次我查看缩略图时都会再次加载图像。
只有一个加载有havint的解决方案吗?
Here is a litle script that preload images and show a thumbnail. Once
you get on the picture you see the real size

It worsk fine with normal picture but when the url has some parameters
like in the sample. The image is loaded again every time I go over the
thumbnail.
Is there a solution for havint just one load?




不是整个缩略图点是一个小的(字节数,

不是屏幕大小)文件?你的剧本失去了这些缩略图的重点。

我不想看到你在

一页上有几个''缩略图'的下载时间。
< br $> b $ b -

-

Fabian

经常长时间访问我的网站!
< a rel =nofollowhref =http://www.lajzar.co.uktarget =_ blank> http://www.lajzar.co.uk



Isnt the whole point of a thumbnail that it is a small (in byte count,
not screen size) file? Your script defeats the point of such thumbnails.
Id hate to see the download time when you have several ''thumbnails'' on
one page.

--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk


你说得对,但我只有大图像。我要找的唯一的东西是
不需要两次下载图像。

想法是看缩略图中的所有图片并且能够

放大一个看看细节而不必等待加载。

***通过Developersdex发送 http://www.developersdex.com ***

不要只是参加USENET ...获得奖励它!
You''re right but I only have the large images. The only things I''m
looking for is not to have to download the image twice.
The idea is to see all the pictures in the thumbnail and be able to
enlarge one to see the details without having to wait for the loading.
*** Sent via Developersdex http://www.developersdex.com ***
Don''t just participate in USENET...get rewarded for it!


michel reynard写道:
michel reynard wrote:
你说得对,但我只有大图像。我要找的唯一的东西是不必下载图像两次。
想法是看缩略图中的所有图片,并能够放大一个看到详细信息,无需等待加载。
You''re right but I only have the large images. The only things I''m
looking for is not to have to download the image twice.
The idea is to see all the pictures in the thumbnail and be able to
enlarge one to see the details without having to wait for the loading.




那么你可能想要预先加载图像。在

加载*小*缩略图的页面上,添加以下代码:


< script type =" text / javascript">

var imageCacher = new Image();

var myImages = [''image1.jpg'',''image2.jpg'',''image3.jpg''。 ..];

for(var i = 0; i< myImages.length; i ++){

imageCacher.src = myImages [i];

}

< / script>


现在,当您的*小*缩略图加载时,浏览器将会收到并且

缓存(根据服务器的规则,任何代理和浏览器的
自己的缓存设置)你想要的每个图像。当用户点击缩略图时,

图像*可能*已经加载。如果没有,你什么也没有丢失,因为你已经下载了* b $ b *小*缩略图,如果它被缓存,它会立即显示为近乎



似乎你想缩略所有大图像以防用户

决定点击其中任何一个。这似乎是一个非常糟糕的想法。我不想等待1MB的图像下载,所以我可以更快地放大




-

| Grant Wagner< gw ***** @ agricoreunited.com>


*客户端Javascript和Netscape 4 DOM参考可从以下位置获得:

*
http:// devedge .netscape.com / library / ... ce / frames.html


* Internet Explorer DOM参考资料:

*
http://msdn.microsoft.com/研讨会/ a ... ence_entry.asp


* Netscape 6/7 DOM参考资料于:

* http://www.mozilla.org/docs/dom/domref/

*为Netscape 7 / Mozilla升级JavaScript的提示

* http://www.mozil la.org/docs/web-deve...upgrade_2.html



Then you''re probably looking to pre-load the images. On the page that
loads *small* thumbnails, add the following code:

<script type="text/javascript">
var imageCacher = new Image();
var myImages = [ ''image1.jpg'', ''image2.jpg'', ''image3.jpg'' ... ];
for (var i = 0; i < myImages.length; i++) {
imageCacher.src = myImages[i];
}
</script>

Now, as your *small* thumbnails load, the browser will be getting and
caching (subject to the rules of the server, any proxies and the browser''s
own cache settings) each image you want. When the user clicks a thumbnail,
the image *may* already be loaded. If not, you''ve lost nothing because you
downloaded *small* thumbnails, if it is cached, it will appear almost
instantly.

It seems that you want to thumbnail all your large images in case the user
decides to click any single one of them. This seems like a really bad
idea. I don''t want to wait for 1MB of images to download so I can enlarge
one more quickly.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html


这篇关于预加载图像不适用于非缓存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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