预加载图像不起作用? [英] pre-loading images not working?

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

问题描述

你好


我在标题中有以下类型的代码


function pre_load_pics()

{

if(document.images)

{

var image1 = new Image(400,265);

image1。 scr =" pic1.jpg";

var image2 = new Image(400,265);

image2.scr =" pic2.jpg";
< br $>
等等


}


以及身体中的以下内容


< script>

pre_load_pics();

< / script>


但是直到应用程序稍后需要它们。

出错了什么?我以为他们应该早点下载?


干杯


Geoff

解决方案
> if(document.images)


这是什么?


Zoe Brown在9/14/2005 6上说了以下内容: 24 AM:

if(document.images)



这是什么?




这是一个测试,看看浏览器是否支持document.images

集合,当测试应该是window.Images

-

兰迪

comp.lang.javascript常见问题 - http://jibbering.com/faq &新闻组每周




" Randy Webb" <您好************ @ aol.com>在消息中写道

新闻:LY ******************** @ comcast.com ...

Zoe布朗在9/14/2005上午6:24发表以下内容:

if(document.images)



这是什么?



这是一个测试,看看浏览器是否支持document.images
集合,当测试应该是window.Images




这就是我的想法,所以Geoff这个值是假的,这个代码只是没有执行,因此为什么你的图像没有被加载。 ..


你本可以尝试自己调试这个并发出提醒,检查你的代码被击中了



Hello

I have following type of code in the header

function pre_load_pics()
{
if (document.images)
{
var image1 = new Image(400,265);
image1.scr = "pic1.jpg";
var image2 = new Image(400,265);
image2.scr = "pic2.jpg";

etc etc

}

and the following in the body

<script>
pre_load_pics();
</script>

but images are not downloaded until the app needs them later.
Something wrong ? I thought they should be downloaded earlier?

Cheers

Geoff

解决方案

> if (document.images)

what is this ?


Zoe Brown said the following on 9/14/2005 6:24 AM:

if (document.images)


what is this ?



It is a test to see if the browser supports the document.images
collection, when the test should be window.Images

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly



"Randy Webb" <Hi************@aol.com> wrote in message
news:LY********************@comcast.com...

Zoe Brown said the following on 9/14/2005 6:24 AM:

if (document.images)


what is this ?



It is a test to see if the browser supports the document.images
collection, when the test should be window.Images



Thats what I thought, so Geoff this value will be false and this code is
simply not executing, hence why your images are not being loaded...

you could have tried to debug this yourself and put in an alert to check
that your code was being hit !


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

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