标题:请教各位,多谢
只看楼主
java在线
Rank: 1
等 级:新手上路
帖 子:93
专家分:0
注 册:2005-7-9
结帖率:100%
 问题点数:0 回复次数:3 
请教各位,多谢
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<html>
<head>
<meta name="generator" content="javascript editor 2">
<title>JavaScript Example</title>
<script language="javascript">
ImgData=new Array(4)
for(var i=0;i<ImgData.length;i++)
{
ImgData[i]=new Image(500,260)
ImgData[i].src="kobe_"+(i+7)+".gif"
}
function Separate(form)
{
var gifName=form.individual.options[form.individual.selectedIndex].value;
document.IMG1.src=gifName;
}
function Cache(form)
{
var gifIndex=form.cached.selectedIndex;
document.IMG2.src=ImgData[gifIndex].src;
}
function checkTimer()
{
if(document.Timer.timerBox.checked)
{
var newIndex=0;
var gifName=document.IMG2.src;
var gifIndex=(gifName.charAt(gifName.length-5))-1;
if(gifIndex<ImgData.length-1)
{
newIndex=gifIndex+1;
}
document.IMG2.src=ImgData[newIndex].src;
document.selections.cached.selectedIndex=newIndex;
var timeoutID=setTimeout("checkTimer()",3000)

}
}
</script>
</head>
<body onLoad=checkTimer()>
<center>
<h2>
Image Object Sample
</h2>
<table border="3">
<tr>
<th></th>
<th>
Individually Loaded
</th>
<th>
Pre-cached
</th>
</tr>
<tr>
<td align=right>
<b>Image:</b>
</td>
<td>
<img src="kobe_1.gif" name="IMG1" height=90 width=120>
</td>
<td>
<img src="kobe_2.gif" name="IMG2" height=90 width=120>
</td>
</tr>
<tr>
<td align=right>
<b>Select Image:</b>
</td>
<form name="selections">
<td>
<select name="individual" onChange="Separate(this.form)">
<option value="kobe_3.gif">
Wires
<option value="kobe_4.gif">
Keyboard
<option value="kobe_5.gif">
Disks
<option value="kobe_6.gif">
Cables
</select>
</td>
<td>
<select name="cached" onChange="Cache(this.form)">
<option value="kobe_7.gif">
Bands
<option Value="kobe_8.gif">
Clips
<option value="kobe_9.gif">
Lamp
<option value="kobe_10.gif">
Erasers
</select>
</td>
</form>
</tr>
</table>
<form name="Timer">
<input type="checkbox" name="timerBox" onClick="checkTimer()">
auto-cycle pre-cached images
</form>
</center>
</body>
</html>

这个程序是执行图片加载的

其中的function checkTimer()函数段实现的是什么东西啊?
请会的人告诉我,多谢了
搜索更多相关主题的帖子: javascript html function content import 
2007-09-27 10:04
lmhllr
Rank: 8Rank: 8
等 级:贵宾
威 望:44
帖 子:1504
专家分:42
注 册:2005-5-12
得分:0 
大概就是那个勾打上的话图片就每隔3秒轮流自动切换
2007-09-27 11:19
java在线
Rank: 1
等 级:新手上路
帖 子:93
专家分:0
注 册:2005-7-9
得分:0 
多谢,但是为什么他只换两副图片呢。。。一共四副呢。。。
2007-09-27 18:59
zhulei1978
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:53
帖 子:1351
专家分:1200
注 册:2006-12-17
得分:0 
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<html>
<head>
<meta name="generator" content="javascript editor 2">
<title>JavaScript Example</title>
<script language="javascript">
ImgData=new Array(4)
for(var i=0;i<ImgData.length;i++)
{
ImgData[i]=new Image(500,260)
ImgData[i].src="kobe_"+(i+7)+".gif"
}
function Separate(form)
{
var gifName=form.individual.options[form.individual.selectedIndex].value;
document.IMG1.src=gifName;
}
function Cache(form)
{
var gifIndex=form.cached.selectedIndex;
document.IMG2.src=ImgData[gifIndex].src;
}
function checkTimer()
{
if(document.Timer.timerBox.checked)
{
var newIndex=0;
var gifName=document.IMG2.src;
var gifIndex=(gifName.charAt(gifName.length-5))-1;
if(gifIndex<ImgData.length+5&&gifIndex>1)
{
newIndex=gifIndex-5;
}
document.IMG2.src=ImgData[newIndex].src;
document.selections.cached.selectedIndex=newIndex;
var timeoutID=setTimeout("checkTimer()",3000)

}
}
</script>
</head>
<body onLoad=checkTimer()>
<center>
<h2>
Image Object Sample
</h2>
<table border="3">
<tr>
<th></th>
<th>
Individually Loaded
</th>
<th>
Pre-cached
</th>
</tr>
<tr>
<td align=right>
<b>Image:</b>
</td>
<td>
<img src="kobe_1.gif" name="IMG1" height=90 width=120>
</td>
<td>
<img src="kobe_2.gif" name="IMG2" height=90 width=120>
</td>
</tr>
<tr>
<td align=right>
<b>Select Image:</b>
</td>
<form name="selections">
<td>
<select name="individual" onChange="Separate(this.form)">
<option value="kobe_3.gif">
Wires
<option value="kobe_4.gif">
Keyboard
<option value="kobe_5.gif">
Disks
<option value="kobe_6.gif">
Cables
</select>
</td>
<td>
<select name="cached" onChange="Cache(this.form)">
<option value="kobe_7.gif">
Bands
<option Value="kobe_8.gif">
Clips
<option value="kobe_9.gif">
Lamp
<option value="kobe_10.gif">
Erasers
</select>
</td>
</form>
</tr>
</table>
<form name="Timer">
<input type="checkbox" name="timerBox" onClick="checkTimer()">
auto-cycle pre-cached images
</form>
</center>
</body>
</html>


其实我就是改变社会风气,提高少女素质,刺激电影市道,提高年轻人内涵,玉树临风,风度翩翩的整蛊专家,我名叫古晶,英文名叫JingKoo!
2007-10-04 20:31



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-173222-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019910 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved