利用Javascript实现的随机刷新的功能实现调用不同图片。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>test Js</title> </head> <body> <script language="javascript"> var New_Array = new Array(); New_Array[0]="http://www.baidu.com/img/logo-yy.gif" New_Array[1]="http://cimg2.163.com/cnews/163/img6/logo.gif" New_Array[2]="http://images.sohu.com/uiue/sohu_logo/beijing2008/2008sohu.gif" var My_time = new Date(); var Now_time = My_time.getSeconds(); alert(Now_time); if (Now_time <20) { document.write("<img src=\""+New_Array[0]+"\" alt\"\" \/>"); } else if (Now_time<40) { document.write("<img src=\""+New_Array[1]+"\" alt\"\" \/>"); } else { document.write("<img src=\""+New_Array[2]+"\" alt\"\" \/>"); } </script> </body> </html>
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]