帮助解决一个简单问题 [英] Help with a Simple Question

查看:84
本文介绍了帮助解决一个简单问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




这是一个新手的问​​题。我想预加载4张图片,只有当所有4张图片都被加载到浏览器的缓存中时,我想开始一个

幻灯片放映()函数。如果图片未完成加载到缓存中,

幻灯片放映看起来不太好。


我不知道如何/何时调用幻灯片()确保它的功能

在预加载完成后启动。


提前感谢您的帮助!


特里


********************************* ***************** ***********

< head>

< script language =" JavaScript" type =" text / JavaScript">

<! -

函数MM_preloadImages(){

var d = document; if(d.images){if(!d.MM_p)d.MM_p = new Array();

var i,j = d.MM_p.length,a = MM_preloadImages.arguments; for(i = 0; i

< a.length; i ++)

if(a [i] .indexOf("#")!= 0) {d.MM_p [j] =新图片; d.MM_p [j ++]。src = a

[i];}}

}


function slideshow(){


.....


}


// - >

< / script>

< / head>


< body onload =" MM_preloadImages('''01.jpg '',''02.jpg'',''03.jpg'',''04.jpg'')">

< / body>

< / html>

Hi,

This is a newbie''s question. I want to preload 4 images and only when
all 4 images has been loaded into browser''s cache, I want to start a
slideshow() function. If images are not completed loaded into cache,
the slideshow doesn''t look very nice.

I am not sure how/when to call the slideshow() function to make sure it
starts after the preload has been completed.

Thanks in advance for your help!

Terry

************************************************** ***********
<head>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() {
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i
<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a
[i];}}
}

function slideshow() {

.....

}

//-->
</script>
</head>

<body onload="MM_preloadImages(''01.jpg'',''02.jpg'',''03.jpg '',''04.jpg'')">
</body>
</html>

推荐答案

文章< MP ***************** *******@news.tc.umn.edu> ;,特里

< go ************** @ REMOVE.yahoo.com>写道:
In article <MP************************@news.tc.umn.edu>, Terry
<go**************@REMOVE.yahoo.com> writes:
这是一个新手的问​​题。我想预加载4张图片,只有当所有4张图片都加载到浏览器的缓存中时,我才想开始一个
幻灯片放映()功能。如果图像未完成加载到缓存中,幻灯片显示看起来不太好。

我不知道如何/何时调用slideshow()函数来确保它<在预加载完成后启动。
This is a newbie''s question. I want to preload 4 images and only when
all 4 images has been loaded into browser''s cache, I want to start a
slideshow() function. If images are not completed loaded into cache,
the slideshow doesn''t look very nice.

I am not sure how/when to call the slideshow() function to make sure it
starts after the preload has been completed.




通过window.onload或body标签加载它:


window.onload = slideshow;


在脚本部分,或:


< body onload =" slideshow()" ;>


该页面不会被视为已加载直到图片也被加载。

-

兰迪



load it via the window.onload or in the body tag:

window.onload = slideshow;

in the script section, or:

<body onload="slideshow()">

The page will not be considered "loaded" until the images are loaded as well.
--
Randy



通过window.onload或body标签加载它:

window.onload = slideshow;

在脚本部分,或者:

< body onload =" slideshow()">

该页面不会被视为已加载直到图像加载为止。

load it via the window.onload or in the body tag:

window.onload = slideshow;

in the script section, or:

<body onload="slideshow()">

The page will not be considered "loaded" until the images are loaded as well.




兰迪,


我做了以上操作。但是,幻灯片开始在所有图像加载之前开始。


Terry



Randy,

I did the above. However, the slideshow starts before all the images
are loaded.

Terry


Terry写道:
Terry wrote:
通过window.onload或body标签加载它:

window.onload = slideshow;

在脚本部分,或:

< body onload =" slideshow()">

页面将不被视为 ;装载"直到图像也被加载。
load it via the window.onload or in the body tag:

window.onload = slideshow;

in the script section, or:

<body onload="slideshow()">

The page will not be considered "loaded" until the images are loaded as well.



兰迪,

我做了以上的事情。但是,幻灯片开始在加载所有图像之前。

特里


Randy,

I did the above. However, the slideshow starts before all the images
are loaded.

Terry




< img src =" image1。 JPG"宽度= QUOT 1 QUOT; height =" 1">

< img src =" image2.jpg"宽度= QUOT 1 QUOT; height =" 1">

< img src =" image3.jpg"宽度= QUOT 1 QUOT; height =" 1">

< img src =" image4.jpg"宽度= QUOT 1 QUOT;每个图片的高度=" 1">


等等。然后使用body的onload或window.onload来

开始幻灯片放映。


或者,你的预加载脚本有问题。如果您无法正常工作,请将URL发布到

样本页面。



<img src="image1.jpg" width="1" height="1">
<img src="image2.jpg" width="1" height="1">
<img src="image3.jpg" width="1" height="1">
<img src="image4.jpg" width="1" height="1">

and so on for each image. Then use the body''s onload or window.onload to
start the slideshow.

Or, something is wrong with your preloading script. Post a URL to a
sample page if you can''t get it working.


这篇关于帮助解决一个简单问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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