<script language="javascript" type="text/javascript">function lastOne()
{
var ads = new Array("images.sohu.com/uiue/sohu_logo/beijing2008/sohu.gif","cn.yimg.com/i/hp/ny/hd/a/yhologo_a.gif","www.tom.com/images/h/logo.gif");
var id = Math.round(Math.random()*10);
var cid = id/3;
var cimg = document.getElementById("img");
cimg.setAttribute("src", "http://"+ads[cid]);
}
</script>
</HEAD><BODY onload="window.setInterval('lastOne()', 2000)">
<img id="img" src="http://images.sohu.com/uiue/sohu_logo/beijing2008/sohu.gif">
</HTML>

解决方案 »

  1.   

    ads//从数据库中读出数据,可用"Ajax"去取。
      

  2.   

       <!--焦点图开始-->      
     <script type="text/javascript">
     <!--
     
     var focus_width=350 //flash宽度定义
     var focus_height=220 //flash高度定义
     var text_height=0 //标题文字行高定义
     var swf_height = focus_height+text_height
     
     var pics='../images/ClubIndexImg/1.jpg|../images/ClubIndexImg/2.jpg|../images/ClubIndexImg/3.jpg|../images/ClubIndexImg/4.jpg|../images/ClubIndexImg/5.jpg|../images/ClubIndexImg/6.jpg'
    //切换图片地址
     var links='#|#|#|#|#|#'
    //链接地址
     var texts='||||' //标题文字
     
     document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
     document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="../css/pixviewer.swf"><param name="quality" value="high"><param name="bgcolor" value="#FFFFFF">');
     document.write('<param name="menu" value="false"><param name=wmode value="/opaque">');
     document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
     document.write('<embed src="pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#DADADA" quality="high" width="'+ focus_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
     document.write('</object>');
     
     //-->
     </script>
     <!--焦点图结束-->这是好多门户网站首页的FLASH广告轮换的例子,你要下载这个pixviewer.swf文件
      

  3.   

    那如何从数据库中随机取出一条记录呢?------------------------------------
    select * from table order by rand() limit 1
      

  4.   

    select * from table order by rand() limit 1
    这个语句说有错误,执行不过去,有人知道这是怎么回事吗?