逐梦论坛's Archiver

shillan 发表于 2006-11-14 23:23

图片循环显示

<img src="http://www.toto369.net/txtx/4.jpg" name=rimage><br><br><br>1.把&lt;body&gt;中内容改为:<br>&lt;body onload="rotateimage('rimage')"&gt;<br>2在head区域中加入如下代码<br><textarea class=yk9 id=source1 name=source1 rows=12 cols=100>&lt;script language="javascript"&gt;
&lt;!-- begin
var interval = 2.5; // delay between rotating images (in seconds)
var random_display = 1; // 0 = no, 1 = yes
interval *= 1000;

var image_index = 0;
image_list = new array();
image_list[image_index++] = new imageitem("1.jpg");
image_list[image_index++] = new imageitem("2.jpg");
image_list[image_index++] = new imageitem("3.jpg");
image_list[image_index++] = new imageitem("4.jpg");
var number_of_image = image_list.length;
function imageitem(image_location) {
this.image_item = new image();
this.image_item.src = image_location;
}
function get_imageitemlocation(imageobj) {
return(imageobj.image_item.src)
}
function generate(x, y) {
var range = y - x + 1;
return math.floor(math.random() * range) + x;
}
function getnextimage() {
if (random_display) {
image_index = generate(0, number_of_image-1);
}
else {
image_index = (image_index+1) % number_of_image;
}
var new_image = get_imageitemlocation(image_list[image_index]);
return(new_image);
}
function rotateimage(place) {
var new_image = getnextimage();
document[place].src = new_image;
var recur_call = "rotateimage('"+place+"')";
settimeout(recur_call, interval);
}
//  end --&gt;
&lt;/script&gt;</textarea> <br><input onclick=source1.select() type=button value=选取代码 name=b23>
<script language=javascript>
<!--
function closeclk() {
another=close();
}
//-->
        </script>
<input onclick=closeclk() type=button value=关闭窗口 name=b222><br><br>加入如下代码到body区域<br><textarea class=yk9 name=source rows=12 cols=100>&lt;img name="rimage" src="1.jpg"&gt;
</textarea> <br><input onclick=source.select() type=button value=选取代码 name=b2>
<script language=javascript>
<!--
function closeclk() {
another=close();
}
//-->
        </script>
<input onclick=closeclk() type=button value=关闭窗口 name=b22>

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.