<div class="codetitle"> <span><a style="CURSOR: pointer" data="53633" class="copybut" id="copybut53633" onclick="doCopy('code53633')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code53633"> <br><script type="text/javascript"> <BR>function strToDate(str, ext) { <BR>if (str == null || str == '') return; <BR>var arys = new Array(); <BR>arys = str.split('-'); <BR>var newDate = new Date(arys[0], arys[1] - 1, arys[2], 9, 0, 0); <BR>if (ext) { <BR>newDate = new Date(newDate.getTime() + 1000 * 60 * 60 * 24); <BR>} <BR>return newDate; <BR>} <BR>start="2012-02-24"; <BR>end="2012-02-27"; <BR>var date = new Date(); <BR>var start = strToDate(start); <BR>var end = strToDate(end, false); <BR>//document.write start.toString(); <BR>str="广告1"; <BR>str2="广告2"; <BR>if (date > start && date <end) { <BR>document.write(str); <BR>}else{ <BR>document.write(str2); <BR>} <BR></script> <br> </div> <br> 需要注意的是,这个是根据客户端的时间判定的,<br>start="2012-02-24"; <br>end="2012-02-27";<br>实际是2.24与2.26号两天内显示的<br>演示代码:<br><div class="htmlarea"><textarea id="runcode61919"> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>JS瀹</title></textarea></div>