日期:2014-05-17  浏览次数:20612 次

如何实现这个功能?
在网页中插入一个image,希望在每次访问或者刷新页面的时候,这个image能够显示不同的图片?

------解决方案--------------------
不知道这个对楼主有没有帮助:

《随机显示图片脚本》
脚本说明:
把如下代码加入 <body> 区域中
<SCRIPT language= "JavaScript "> <!--

today=new Date();

jran=today.getTime();


function rnd() {


ia=9301;

ic=49297;

im=233280;


jran = (jran*ia+ic) % im;

return jran/(im*1.0);

};


function rand(number) {


return Math.ceil(rnd()*number);

};


document.write( " <CENTER> ");

for(i=1;i <=1;i++) {

myNum=(rand(10)); //改成你要随机显示的图片数;

if(myNum == 1) document.write( " <img src= 'back.jpg '> ");

if(myNum == 2) document.write( " <img src= 'j2.gif '> "); //图片路径,可用http://

if(myNum == 3) document.write( " <img src= 'email.gif '> ");

if(myNum == 4) document.write( " <img src= 'arrow.gif '> ");

if(myNum == 5) document.write( " <img src= 'j2.gif '> ");

if(myNum == 6) document.write( " <img src= 'email.gif '> ");

if(myNum == 7) document.write( " <img src= 'arrow.gif '> ");

if(myNum == 8) document.write( " <img src= 'j2.gif '> ");

if(myNum == 9) document.write( " <img src= 'back.jpg '> ");

if(myNum == 10) document.write( " <img src= 'email.gif '> ");

else {

document.write();

}
};
document.write( " </CENTER> ");
//-->


</SCRIPT>