87,910
社区成员
发帖
与我相关
我的任务
分享
<script>
function getDateDiff(date1,date2){
var re = /^(\d{4})\S(\d{1,2})\S(\d{1,2})$/;
var dt1,dt2;
if (re.test(date1))
{
dt1 = new Date(RegExp.$1,RegExp.$2 - 1,RegExp.$3);
}
if (re.test(date2))
{
dt2 = new Date(RegExp.$1,RegExp.$2 - 1,RegExp.$3);
}
return Math.floor((dt2-dt1)/(1000 * 60 * 60 * 24))
}
Date.prototype.format = function(format){
var o = {
"M+" : this.getMonth()+1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
"S" : this.getMilliseconds() //millisecond
}
if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
(this.getFullYear()+"").substr(4 - RegExp.$1.length));
for(var k in o)if(new RegExp("("+ k +")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length==1 ? o[k] :
("00"+ o[k]).substr((""+ o[k]).length));
return format;
};
</script>
</head>
<body>
<div align='center'>
<div id='name'>name</div>
</div>
</font>
<script>
var count = getDateDiff('2010-04-15', new Date().format("yyyy-MM-dd"))%5;
if(count == 0){
document.getElementById('name').firstChild.nodeValue = "领导1";
}else if(count == 1){
document.getElementById('name').firstChild.nodeValue = "领导2";
}else if(count == 2){
document.getElementById('name').firstChild.nodeValue = "领导3";
}else if(count == 3){
document.getElementById('name').firstChild.nodeValue = "领导4";
}else if(count == 4){
document.getElementById('name').firstChild.nodeValue = "领导5";
}
</script>
<script>
function getDateDiff(date1,date2){
var re = /^(\d{4})\S(\d{1,2})\S(\d{1,2})$/;
var dt1,dt2;
if (re.test(date1))
{
dt1 = new Date(RegExp.$1,RegExp.$2 - 1,RegExp.$3);
}
if (re.test(date2))
{
dt2 = new Date(RegExp.$1,RegExp.$2 - 1,RegExp.$3);
}
return Math.floor((dt2-dt1)/(1000 * 60 * 60 * 24))
}
Date.prototype.format = function(format){
var o = {
"M+" : this.getMonth()+1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
"S" : this.getMilliseconds() //millisecond
}
if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
(this.getFullYear()+"").substr(4 - RegExp.$1.length));
for(var k in o)if(new RegExp("("+ k +")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
return format;
};
</script>
</head>
<body>
<div align='center'>
<div id='pic'><img id="photo" src=""></div><!-- 加了个放照片的div -->
<div id='name'>name</div>
</div>
</font>
<script>
//照片路径数组
var arr = new Array()
arr = [
"http://www.gov.cn/gjjg/images/images/00188b27c9090945a55001_small.jpg",
"http://www.gov.cn/gjjg/images/images/00188b27c9090946d9e60e_small.jpg",
"http://www.gov.cn/gjjg/images/images/00188b27c9090945a51f01_small.jpg",
"http://www.gov.cn/gjjg/images/images/0011431a94e609487b2601_small.jpg",
"http://www.gov.cn/gjjg/images/images/0011431a94e609487a4601_small.jpg"
];
var count = getDateDiff('2010-04-15', new Date().format("yyyy-MM-dd"))%5;
switch(count){
case 0 :
document.getElementById('name').firstChild.nodeValue = "领导1";
case 1:
document.getElementById('name').firstChild.nodeValue = "领导2";
case 2:
document.getElementById('name').firstChild.nodeValue = "领导3";
case 3:
document.getElementById('name').firstChild.nodeValue = "领导4";
case 4:
document.getElementById('name').firstChild.nodeValue = "领导5";
default:
document.getElementById("photo").src = arr[count];//给图片加路径
}
</script>
function showPic(name){
var img= document.createElement("img");
img.setAttribute("src",name);
document.getElementById("name").appendChild(img);
}
<html>
<head>
<script>
function showPic(name){
var img= document.createElement("img");
img.setAttribute("src",name);
document.getElementById("name").appendChild(img);
}
</script>
</head>
<body>
<div id='name'></div>
<script>
var count = getDateDiff('2010-05-29', new Date().format("yyyy-MM-dd"))%5;
if(count == 0){
showPic("http://www.gov.cn/gjjg/images/images/00188b27c9090945a55001_small.jpg");
}else if(count == 1){
showPic("http://www.gov.cn/gjjg/images/images/00188b27c9090946d9e60e_small.jpg");
}else if(count == 2){
showPic("http://www.gov.cn/gjjg/images/images/00188b27c9090945a51f01_small.jpg");
}else if(count == 3){
showPic("http://www.gov.cn/gjjg/images/images/0011431a94e609487b2601_small.jpg");
}else if(count == 4){
showPic("http://www.gov.cn/gjjg/images/images/0011431a94e609487a4601_small.jpg");
}
</script>
</body>
</html>
function showPic(name){
var img= document.createElement("img");
img.setAttribute("src",name);
document.getElementById("name").appendChild(img);
}
<div id='name'></div>
<script>
var count = getDateDiff('2010-05-29', new Date().format("yyyy-MM-dd"))%5;
if(count == 0){
showPic("http://www.gov.cn/gjjg/images/images/00188b27c9090945a55001_small.jpg");
}else if(count == 1){
showPic("http://www.gov.cn/gjjg/images/images/00188b27c9090946d9e60e_small.jpg");
}else if(count == 2){
showPic("http://www.gov.cn/gjjg/images/images/00188b27c9090945a51f01_small.jpg");
}else if(count == 3){
showPic("http://www.gov.cn/gjjg/images/images/0011431a94e609487b2601_small.jpg");
}else if(count == 4){
showPic("http://www.gov.cn/gjjg/images/images/0011431a94e609487a4601_small.jpg");
}
</script>