有一个网站,需要每日更换图片,引用的图片地址按日期每日更新。
如何能实现?谢谢指教!网站代码如下:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="Web Page Maker"><style type="text/css">
/*----------Text Styles----------*/
.ws6 {font-size: 8px;}
.ws7 {font-size: 9.3px;}
.ws8 {font-size: 11px;}
.ws9 {font-size: 12px;}
.ws10 {font-size: 13px;}
.ws11 {font-size: 15px;}
.ws12 {font-size: 16px;}
.ws14 {font-size: 19px;}
.ws16 {font-size: 21px;}
.ws18 {font-size: 24px;}
.ws20 {font-size: 27px;}
.ws22 {font-size: 29px;}
.ws24 {font-size: 32px;}
.ws26 {font-size: 35px;}
.ws28 {font-size: 37px;}
.ws36 {font-size: 48px;}
.ws48 {font-size: 64px;}
.ws72 {font-size: 96px;}
.wpmd {font-size: 13px;font-family: 'Arial';font-style: normal;font-weight: normal;}
/*----------Para Styles----------*/
DIV,UL,OL /* Left */
{
 margin-top: 0px;
 margin-bottom: 0px;
}
</style></head><body><div id="image2" style="position:absolute; overflow:hidden; left:80px; top:20px; width:200px; height:296px; z-index:0"><img src="http://image2.idoican.com.cn/074/2010-07-26/001/List.jpg" alt="" title="" border=0 width=200 height=296></div></body>
</html>
试了几天,没法解决请高手帮忙看下,谢谢!

解决方案 »

  1.   

    <body onload="setImg()"><img id="x">在setImg里根据日期设置src就可以了
      

  2.   

    我写了个示例,供参考:
    在桌面上建一个html文件,再建一个images目录,里面放三张图片,命名为“2010-7-28.jpg"、“2010-7-29.jpg"、“2010-7-30.jpg"。html源代码:<html>
    <head>
    <script>
    function update(XelementID)
    {
        var myDate = new Date();
        var year = myDate.getFullYear();
        var month = myDate.getMonth() + 1;
        var date = myDate.getDate();
        document.getElementById(XelementID).src="images//"+year+"-"+month+"-"+date+".jpg";
    }
    </script>
    </head>
    <body>
    <img id="abc" src="" />
    <div id="javascript"><script>update("abc");</script></div>
    </body>
    </html>如果运行此html文件时日期为2010-7-29,那么它将会显示对应日期的那张图片。
    基本方法就是这样,你可以改下。