<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script id="allmobilize" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>
<title>根据日期切换图片KFX</title>
</head>
<body>
<span id="kfx" style="display:none;"></span>
<div id="kfx_bg" style="height:440px;background-color:red;"></div>
<script type="text/javascript">
function showLocale(objD)
{
var str,colorhead,colorfoot;
var yy = objD.getYear();
if(yy<1900) yy = yy+1900;
var MM = objD.getMonth()+1;
if(MM<10) MM = '0' + MM;
var dd = objD.getDate();
if(dd<10) dd = '0' + dd;
var hh = objD.getHours();
if(hh<10) hh = '0' + hh;
var mm = objD.getMinutes();
if(mm<10) mm = '0' + mm;
var ss = objD.getSeconds();
if(ss<10) ss = '0' + ss;
var ww = objD.getDay();
if ( ww==0 ) colorhead="<font color=\"#FF0000\">";
if ( ww > 0 && ww < 6 ) colorhead="";
if ( ww==6 ) colorhead="<font color=\"#008000\">";
colorfoot=""
str = colorhead+ MM + "-" + dd ;
return(str);
}
function tick()
{
var today;
today = new Date();
document.getElementById("kfx").innerHTML = showLocale(today);
//立春2月4日
if(showLocale(today)=="11-01"){
$(function(){
$("#kfx_bg").css("background-image","url('spring.png')");
//$("#kfx_bg").css("background-image","url('http://www.baidu.com/img/bdlogo.gif')");
})
}
//立夏5月5号或6号
else if(showLocale(today)=="05-05"){
$(function(){
$("#kfx_bg").css("background-image","url('summer.png')");
})
}
//立秋9月23日或24日
else if(showLocale(today)=="09-23"){
$(function(){
$("#kfx_bg").css("background-image","url('autumn.png')");
})
}
//立冬11月7号
else if(showLocale(today)=="11-07"){
$(function(){
$("#kfx_bg").css("background-image","url('winter.png')");
})
}
//五一
else if(showLocale(today)=="05-01"){
$(function(){
$("#kfx_bg").css("background-image","url('wuyi.png')");
})
}
//国庆
else if(showLocale(today)=="10-01"){
$(function(){
$("#kfx_bg").css("background-image","url('guoqing.png')");
})
}
;
}
tick();
</script>
</body>
</html>
根据日期切换图片KFX
最新推荐文章于 2022-06-15 17:46:10 发布