***时间日期***一个非常不错的日期特效
把下列代码加到网页的<body></body>标签之间 从google下载我的照片管理软件<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<!-- saved from url=(0050)http://www2.yesky.com/34603008/tr1010-xiaoguo2.htm -->
<html><head><title></title>
<meta content="text/html; charset=gb2312" http-equiv=content-type>
<script language=javascript1.2>
// 一个简单的测试是否ie浏览器的表达式
isie = (document.all ? true : false);
// 得到ie中各元素真正的位移量,即使这个元素在一个表格中
function getieposx(elt) { return getiepos(elt,"left"); }
function getieposy(elt) { return getiepos(elt,"top"); }
function getiepos(elt,which) {
ipos = 0
while (elt!=null) {
ipos += elt["offset" + which]
elt = elt.offsetparent
}
return ipos
}
function getxbrowserref(eltname) {
return (isie ? document.all.style : document.layers);
}
function hideelement(eltname) { getxbrowserref(eltname).visibility = 'hidden'; }
// 按不同的浏览器进行处理元件的位置
function moveby(elt,deltax,deltay) {
if (isie) {
elt.left = elt.pixelleft + deltax;
elt.top = elt.pixeltop + deltay;
} else {
elt.left += deltax;
elt.top += deltay;
}
}
function togglevisible(eltname) {
elt = getxbrowserref(eltname);
if (elt.visibility == 'visible' || elt.visibility == 'show') {
elt.visibility = 'hidden';
} else {
fixposition(eltname);
elt.visibility = 'visible';
}
}
function setposition(elt,positionername,isplacedunder) {
positioner = null;
if (isie) {
positioner = document.all;
elt.left = getieposx(positioner);
elt.top = getieposy(positioner);
} else {
positioner = document.images;
elt.left = positioner.x;
elt.top = positioner.y;
}
if (isplacedunder) { moveby(elt,0,positioner.height); }
}
//——————————————————————————————————————
// 判断浏览器
isie = (document.all ? true : false);
// 初始月份及各月份天数数组
var months = new array("一 月", "二 月", "三 月", "四 月", "五 月", "六 月", "七 月",
"八 月", "九 月", "十 月", "十一月", "十二月");
var daysinmonth = new array(31, 28, 31, 30, 31, 30, 31, 31,
30, 31, 30, 31);
var displaymonth = new date().getmonth();
var displayyear = new date().getfullyear();
var displaydivname;
var displayelement;
function getdays(month, year) {
//测试选择的年份是否是润年?
if (1 == month)
return ((0 == year % 4) && (0 != (year % 100))) ||
(0 == year % 400) ? 29 : 28;
else
return daysinmonth;
}
function gettoday() {
// 得到今天的日期
this.now = new date();
this.year = this.now.getfullyear();
this.month = this.now.getmonth();
this.day = this.now.getdate();
}
// 并显示今天这个月份的日历
today = new gettoday();
function newcalendar(eltname,attachedelement) {
if (attachedelement) {
if (displaydivname && displaydivname != eltname) hideelement(displaydivname);
displayelement = attachedelement;
}
displaydivname = eltname;
today = new gettoday();
var parseyear = parseint(displayyear + '');
var newcal = new date(parseyear,displaymonth,1);
var day = -1;
var startdayofweek = newcal.getday();
if ((today.year == newcal.getfullyear()) &&
(today.month == newcal.getmonth()))
{
day = today.day;
}
var intdaysinmonth =
getdays(newcal.getmonth(), newcal.getfullyear());
var daysgrid = makedaysgrid(startdayofweek,day,intdaysinmonth,newcal,eltname)
if (isie) {
var elt = document.all;
elt.innerhtml = daysgrid;
} else {
var elt = document.layers.document;
elt.open();
elt.write(daysgrid);
elt.close();
}
}
function incmonth(delta,eltname) {
displaymonth += delta;
if (displaymonth >= 12) {
displaymonth = 0;
incyear(1,eltname);
} else if (displaymonth <= -1) {
displaymonth = 11;
incyear(-1,eltname);
} else {
newcalendar(eltname);
}
}
function incyear(delta,eltname) {
displayyear = parseint(displayyear + '') + delta;
newcalendar(eltname);
}
function makedaysgrid(startday,day,intdaysinmonth,newcal,eltname) {
var daysgrid;
var month = newcal.getmonth();
var year = newcal.getfullyear();
var isthisyear = (year == new date().getfullyear());
var isthismonth = (day > -1)
daysgrid = '<table border=1 cellspacing=0 cellpadding=2><tr><td bgcolor=#ffffff nowrap>';
daysgrid += '<font face="courier new, courier" size=2>';
daysgrid += '<a href="javascript:hideelement(\'' + eltname + '\')">x</a>';
daysgrid += '';
daysgrid += '<a href="javascript:incmonth(-1,\'' + eltname + '\')">? </a>';
daysgrid += '<b>';
if (isthismonth) { daysgrid += '<font color=red>' + months + '</font>'; }
else { daysgrid += months; }
daysgrid += '</b>';
daysgrid += '<a href="javascript:incmonth(1,\'' + eltname + '\')"> ?</a>';
daysgrid += ' ';
daysgrid += '<a href="javascript:incyear(-1,\'' + eltname + '\')">? </a>';
daysgrid += '<b>';
if (isthisyear) { daysgrid += '<font color=red>' + year + '</font>'; }
else { daysgrid += ''+year; }
daysgrid += '</b>';
daysgrid += '<a href="javascript:incyear(1,\'' + eltname + '\')"> ?</a><br>';
daysgrid += ' su mo tu we th fr sa <br> ';
var dayofmonthoffirstsunday = (7 - startday + 1);
for (var intweek = 0; intweek < 6; intweek++) {
var dayofmonth;
for (var intday = 0; intday < 7; intday++) {
dayofmonth = (intweek * 7) + intday + dayofmonthoffirstsunday - 7;
if (dayofmonth <= 0) {
daysgrid += " ";
} else if (dayofmonth <= intdaysinmonth) {
var color = "blue";
if (day > 0 && day == dayofmonth) color="red";
daysgrid += '<a href="javascript:setday(';
daysgrid += dayofmonth + ',\'' + eltname + '\')" '
daysgrid += 'style="color:' + color + '">';
var daystring = dayofmonth + "</a> ";
if (daystring.length == 6) daystring = '0' + daystring;
daysgrid += daystring;
}
}
if (dayofmonth < intdaysinmonth) daysgrid += "<br> ";
}
return daysgrid + "</td></tr></table>";
}
function setday(day,eltname) {
displayelement.value = (displaymonth + 1) + "/" + day + "/" + displayyear;
hideelement(eltname);
}
//——————————————————————————————————————
<!--
// fixposition() 这个函数和前面所讲的那个函数一样
//
function fixposition(eltname) {
elt = getxbrowserref(eltname);
positionerimgname = eltname + 'pos';
// hint: try setting isplacedunder to false
isplacedunder = false;
if (isplacedunder) {
setposition(elt,positionerimgname,true);
} else {
setposition(elt,positionerimgname)
}
}
function toggledatepicker(eltname,formelt) {
var x = formelt.indexof('.');
var formname = formelt.substring(0,x);
var formeltname = formelt.substring(x+1);
newcalendar(eltname,document.forms.elements);
togglevisible(eltname);
}
// fixpositions() 这个函数前面也讲过
function fixpositions()
{
fixposition('daysofmonth');
fixposition('daysofmonth2');
}
// -->
</script>
<meta content="mshtml 5.00.2920.0" name=generator></head>
<body bgcolor=#ffffff onresize=fixpositions()>
<p>
<form name=date>
<center>
<table border=1 width=225>
<tbody>
<tr>
<td width=89>开始日期: </td>
<td width=120><input name=ret size=10> <img align=absmiddle
alt="date picker" border=0 height=19 id=daysofmonthpos name=daysofmonthpos
onmouseup="toggledatepicker('daysofmonth','date.ret')"
src="tr1010-xiaoguo2.files/tr1010-calendaricon.gif" width=19>
http://code.ik8.com/html/tr1010-xiaoguo2.files/tr1010-calendaricon.gif<div id=daysofmonth style="position: absolute"></div></td></tr>
<tr>
<td width=89>终止日期: </td>
<td width=120><input name=ret2 size=10> <img align=absmiddle
alt="date picker" border=0 height=19 id=daysofmonth2pos
name=daysofmonth2pos
onmouseup="toggledatepicker('daysofmonth2','date.ret2')"
src="tr1010-xiaoguo2.files/tr1010-calendaricon.gif" width=19>
http://code.ik8.com/html/tr1010-xiaoguo2.files/tr1010-calendaricon.gif<div id=daysofmonth2
style="position: absolute"></div></td></tr></tbody></table></center></form>
<p>
<script language=javascript1.2>
function cancel() {
hideelement("daysofmonth");
}
</script>
<script language=javascript1.2>
<!--
hideelement('daysofmonth');
hideelement('daysofmonth2');
//-->
</script>
</p></body></html>
----------------------- -- -------------
http://www.huoyue. com.cn 活跃网,活跃人群的论坛,访 问活跃网,将给您带来意 想不到的收获,还可以免费为您开论坛 ,让 您免费拥有与朋友、网友交流的论坛。你是年轻人吗?你活跃你就 上!
页:
[1]