<script LANGUAGE="JavaScript">
<!--
function isnew(maxdays, addDate){    var oldDate = new Date(addDate);
    var newDate = new Date();
    var maxdaysold = maxdays*24*60*60*1000;
    var psj=0;
    
    if ((newDate.getTime()-oldDate.getTime()) <= maxdaysold) {
        document.write("<img src=pic.jpg width=400 height=40 ALIGN=MIDDLE Alt='New'>");
    }
}
//-->
</script><script LANGUAGE="JavaScript">
<!--
isnew(7,"05/14/2000")
//-->
</script>这段代码的具体意思上设定了红色的时间后7天的时间内显示上面蓝色的图片。我现在想超过7天后一直使用另外一张图片要怎么修改这段代码呢?

解决方案 »

  1.   


    <script LANGUAGE="JavaScript">
    <!--
    function isnew(maxdays, addDate){    var oldDate = new Date(addDate);
        var newDate = new Date();
        var maxdaysold = maxdays*24*60*60*1000;
        var psj=0;

       
        if ((newDate.getTime()-oldDate.getTime()) <= maxdaysold) {
            document.write(" <img src=pic.jpg width=400 height=40 ALIGN=MIDDLE Alt='New'>");
        }
    else{
            document.write(" <img src=another.jpg width=400 height=40 ALIGN=MIDDLE Alt='Another'>");
    }


    }
    //-->
    </script>
    <script LANGUAGE="JavaScript">
    <!--
    isnew(7,"10/15/2009")
    //-->
    </script> 
      

  2.   

        if ((newDate.getTime()-oldDate.getTime()) <= maxdaysold) { 
            document.write(" <img src=pic.jpg width=400 height=40 ALIGN=MIDDLE Alt='New'>"); 
        }else{
            document.write(" <img src=pic1.jpg width=400 height=40 ALIGN=MIDDLE Alt='Old'>"); 
        }
    加个else条件
      

  3.   

    也许LZ想要的是这个
        if ((newDate.getTime()-oldDate.getTime()) > maxdaysold){ 
            document.write(" <img src=pic1.jpg width=400 height=40 ALIGN=MIDDLE Alt='Old'>"); 
        }