此代码可根据当天日期函数弹出广告。
![]()
Code
//判断日期是否大于今天,如isLaterDate("2010-1-1")返回true
function isLaterDate(d){
try{
var now = new Date();
var dateArr = d.split("-");
var arrLen = dateArr.length;
now.setFullYear(now.getYear(), now.getMonth(), now.getDate());
var checkDate = new Date();
checkDate.setFullYear(dateArr[0], dateArr[1]-1, dateArr[2]);
var nowTime = now.getTime();
var checkTime = checkDate.getTime();
if(nowTime < checkTime){
return true;
}else{
return false;
}
}catch(e){return false;}
}
if((location.href=="http://www.chfdcj.com/" || location.href=="http://www.chfdcj.gov.cn/")&& isLaterDate("2009-6-10"))
{window.open("/include/welcome.html","ss","height=400,width=400,left=" + (screen.availWidth-400)/2 + ",top=" + (screen.availHeight-400)/2 + ";toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");}
效果图如下
这是一种比较土的办法,当然还可以使用cookie判断的方式(原文:http://www.51obj.cn/)