Wed

18

Mar

2009

60、跟随鼠标时钟

60、跟随鼠标时钟

脚本说明:

把如下代码加入<body>区域中

<script language="JavaScript">

<!--

fCol='00ffff';//face colour.

dCol='fff000';//dot colour.

hCol='ff0000';//hours colour.

mCol='00ff00';//minutes colour.

sCol='7788ff';//seconds colour.

ClockHeight=35;

ClockWidth=35;

ClockFromMouseY=80;

ClockFromMouseX=5;

 

//Alter nothing below! Alignments will be lost!

ns=(document.layers);

ie=(document.all);

h=3;

m=4;

s=5;

face='1 2 3 4 5 6 7 8 9 10 11 12';

face=face.split(' ');

n=face.length;

speed=0.6;

ymouse=0;

xmouse=0;

scrll=0;

p="<font face=Arial size=1 color="+fCol+">";

e=360/n;

HandHeight=ClockHeight/4;

HandWidth=ClockWidth/4;

HandY=0;

HandX=0;

scrll=0;

y=new Array();x=new Array();Y=new Array();X=new Array();

for (i=0; i < 37; i++){y[i]=0;x[i]=0;Y[i]=0;X[i]=0}

Dy=new Array();Dx=new Array();DY=new Array();DX=new Array();

for (i=0; i < n; i++){Dy[i]=0;Dx[i]=0;DY[i]=0;DX[i]=0}

if (ns){

for (i=0; i < n; i++)

document.write('<layer name="nsN'+i+'" top=0 left=0 height=15 width=15><center>'+p+face[i]+'</font></center></layer>');

for (i=0; i < n; i++)

document.write('<layer name="nsD'+i+'" top=0 left=0 bgcolor='+dCol+' clip="0,0,2,2"></layer>');

for (i=0; i < h; i++)

document.write('<layer name=nsH'+i+' top=0 left=0 bgcolor='+hCol+' clip="0,0,2,2"></layer>');

for (i=0; i < m; i++)

document.write('<layer name=nsM'+i+' top=0 left=0 bgcolor='+mCol+' clip="0,0,2,2"></layer>');

for (i=0; i < s; i++)

document.write('<layer name=nsS'+i+' top=0 left=0 bgcolor='+sCol+' clip="0,0,2,2"></layer>');

}

if (ie){

document.write('<div id="On" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i=0; i < n; i++)

document.write('<div id="ieN" style="position:absolute;width:15px;height:15px;text-align:center">'+p+face[i]+'</font></div>');

document.write('</div></div>');

document.write('<div id="Od" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i=0; i < n; i++)

document.write('<div id="ieD" style="position:absolute;height:2px;width:2px;font-size:2px;background:'+dCol+'"></div>');

document.write('</div></div>');

document.write('<div id="Oh" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i=0; i < h; i++)

document.write('<div id="ieH" style="position:absolute;width:2px;height:2px;font-size:2px;background:'+hCol+'"></div>');

document.write('</div></div>');

document.write('<div id="Om" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i=0; i < m; i++)

document.write('<div id="ieM" style="position:absolute;width:2px;height:2px;font-size:2px;background:'+mCol+'"></div>');

document.write('</div></div>')

document.write('<div id="Os" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i=0; i < s; i++)

document.write('<div id="ieS" style="position:absolute;width:2px;height:2px;font-size:2px;background:'+sCol+'"></div>');

document.write('</div></div>')

}

 

(ns)?window.captureEvents(Event.MOUSEMOVE):0;

function Mouse(evnt){

ymouse = (ns)?evnt.pageY+ClockFromMouseY-(window.pageYOffset):event.y+ClockFromMouseY;

xmouse = (ns)?evnt.pageX+ClockFromMouseX:event.x+ClockFromMouseX;

}

(ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse;

 

function ClockAndAssign(){

time = new Date ();

secs = time.getSeconds();

sec = -1.57 + Math.PI * secs/30;

mins = time.getMinutes();

min = -1.57 + Math.PI * mins/30;

hr = time.getHours();

hrs = -1.575 + Math.PI * hr/6+Math.PI*parseInt(time.getMinutes())/360;

if (ie){

On.style.top=window.document.body.scrollTop;

Od.style.top=window.document.body.scrollTop;

Oh.style.top=window.document.body.scrollTop;

Om.style.top=window.document.body.scrollTop;

Os.style.top=window.document.body.scrollTop;

}

for (i=0; i < s; i++){

 var sd=(ns)?document.layers['nsS'+i]:ieS[i].style;

 sd.top=y[8+i]+HandY+(i*HandHeight)*Math.sin(sec)+scrll;

 sd.left=x[8+i]+HandX+(i*HandWidth)*Math.cos(sec);

}

for (i=0; i < m; i++){

 var md=(ns)?document.layers['nsM'+i]:ieM[i].style;

 md.top=y[4+i]+HandY+(i*HandHeight)*Math.sin(min)+scrll;

 md.left=x[4+i]+HandX+(i*HandWidth)*Math.cos(min);

}

for (i=0; i < h; i++){

 var hd=(ns)?document.layers['nsH'+i]:ieH[i].style;

 hd.top=y[1+i]+HandY+(i*HandHeight)*Math.sin(hrs)+scrll;

 hd.left=x[1+i]+HandX+(i*HandWidth)*Math.cos(hrs);

}

for (i=0; i < n; i++){

 var D=(ns)?document.layers['nsD'+i]:ieD[i].style;

 D.top=y[13+i] + ClockHeight*Math.sin(-1.0471 + i*e*Math.PI/180)+scrll;

 D.left=x[13+i] + ClockWidth*Math.cos(-1.0471 + i*e*Math.PI/180);

}

for (i=0; i < n; i++){

 var N=(ns)?document.layers['nsN'+i]:ieN[i].style;

 N.top=y[25+i]-6 + ClockHeight*1.4*Math.sin(-1.0471 + i*e*Math.PI/180)+scrll;

 N.left=x[25+i]-6 + ClockWidth*1.4*Math.cos(-1.0471 + i*e*Math.PI/180);

}

}

 

function Delay(){

scrll=(ns)?window.pageYOffset:0;

y[0]=Math.round(Y[0]+=((ymouse)-Y[0])*speed);

x[0]=Math.round(X[0]+=((xmouse)-X[0])*speed);

for (i=1; i < 37; i++){

y[i]=Math.round(Y[i]+=(y[i-1]-Y[i])*speed);

x[i]=Math.round(X[i]+=(x[i-1]-X[i])*speed);

}

ClockAndAssign();

setTimeout('Delay()',20);

}

if (ns||ie)window.onload=Delay;

//-->

</script>

 

0 Comments

Wed

18

Mar

2009

59、又一日期的选择

59、又一日期的选择

脚本说明:

把如下代码加入<body>区域中

<script language="javascript">

 

 

// default settings

var fontFace="verdana";

var fontSize=9;

 

var titleWidth=90;

var titleMode=1;

var dayWidth=12;

var dayDigits=1;

 

var titleColor="#cccccc";

var daysColor="#cccccc";

var bodyColor="#ffffff";

var dayColor="#ffffff";

var currentDayColor="#333333";

var footColor="#cccccc";

var borderColor="#333333";

 

var titleFontColor = "#333333";

var daysFontColor = "#333333";

var dayFontColor = "#333333";

var currentDayFontColor = "#ffffff";

var footFontColor = "#333333";

 

var calFormat = "yyyy/mm/dd";

 

var weekDay = 0;

// ------

 

// codes

var calWidth=200, calHeight=200, calOffsetX=-200, calOffsetY=16;

var calWin=null;

var winX=0, winY=0;

var cal="cal";

var cals=new Array();

var currentCal=null;

 

var yxMonths=new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

var yxDays=new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");

var yxLinks=new Array("[close]", "[clear]");

 

var isOpera=(navigator.userAgent.indexOf("Opera")!=-1)?true:false;

var isOpera5=(navigator.appVersion.indexOf("MSIE 5")!=-1 && navigator.userAgent.indexOf("Opera 5")!=-1)?true:false;

var isOpera6=(navigator.appVersion.indexOf("MSIE 5")!=-1 && navigator.userAgent.indexOf("Opera 6")!=-1)?true:false;

var isN6=(navigator.userAgent.indexOf("Gecko")!=-1);

var isN4=(document.layers)?true:false;

var isMac=(navigator.userAgent.indexOf("Mac")!=-1);

var isIE=(document.all && !isOpera && (!isMac || navigator.appVersion.indexOf("MSIE 4")==-1))?true:false;

 

if (isN4) {

  fontSize+=2;

}

 

var span2="</span>";

 

function span1(tag) {

  return "<span class='"+tag+"'>";

}

function spanx(tag, color) {

  return "."+tag+" { font-family:"+fontFace+"; font-size:"+fontSize+"px; color:"+color+"; }\n";

}

 

function a1(tag) {

  return "<a class='"+tag+"' href=";

}

 

function ax(tag, color) {

  return "."+tag+" { text-decoration:none; color:"+color+"; }\n";

}

 

function calOBJ(name, title, field, form) {

  this.name = name;

  this.title = title;

  this.field = field;

  this.formName = form;

  this.form = null

}

 

function setFont(font, size) {

  if (font != "") {

    fontFace=font;

  }

  if (size > 0) {

    fontSize=size;

 

    if (isN4) {

      fontSize+=2;

    }

  }

}

 

function setWidth(tWidth, tMode, dWidth, dDigits) {

  if (tWidth > 0) {

    titleWidth=tWidth;

  }

  if (tMode == 1 || tMode == 2) {

    titleMode=tMode;

  }

  if (dWidth > 0) {

    dayWidth=dWidth;

  }

  if (dDigits > 0) {

    dayDigits=dDigits;

  }

}

 

function setColor(tColor, dsColor, bColor, dColor, cdColor, fColor, bdColor) {

  if (tColor != "") {

    titleColor=tColor;

  }

  if (dsColor != "") {

    daysColor=dsColor;

  }

  if (bColor != "") {

    bodyColor=bColor;

  }

  if (dColor != "") {

    dayColor=dColor;

  }

  if (cdColor != "") {

    currentDayColor=cdColor;

  }

  if (fColor != "") {

    footColor=fColor;

  }

  if (bdColor != "") {

    borderColor=bdColor;

  }

}

 

function setFontColor(tColorFont, dsColorFont, dColorFont, cdColorFont, fColorFont) {

  if (tColorFont != "") {

    titleFontColor=tColorFont;

  }

  if (dsColorFont != "") {

    daysFontColor=dsColorFont;

  }

  if (dColorFont != "") {

    dayFontColor=dColorFont;

  }

  if (cdColorFont != "") {

    currentDayFontColor=cdColorFont;

  }

  if (fColorFont != "") {

    footFontColor=fColorFont;

  }

}

 

function setFormat(format) {

  calFormat = format;

}

 

function setSize(width, height, ox, oy) {

  if (width > 0) {

    calWidth=width;

  }

  if (height > 0) {

    calHeight=height;

  }

 

  calOffsetX=ox;

  calOffsetY=oy;

}

 

function setWeekDay(wDay) {

  if (wDay == 0 || wDay == 1) {

    weekDay = wDay;

  }

}

 

function setMonthNames(janName, febName, marName, aprName, mayName, junName, julName, augName, sepName, octName, novName, decName) {

  if (janName != "") {

    yxMonths[0] = janName;

  }

  if (febName != "") {

    yxMonths[1] = febName;

  }

  if (marName != "") {

    yxMonths[2] = marName;

  }

  if (aprName != "") {

    yxMonths[3] = aprName;

  }

  if (mayName != "") {

    yxMonths[4] = mayName;

  }

  if (junName != "") {

    yxMonths[5] = junName;

  }

  if (julName != "") {

    yxMonths[6] = julName;

  }

  if (augName != "") {

    yxMonths[7] = augName;

  }

  if (sepName != "") {

    yxMonths[8] = sepName;

  }

  if (octName != "") {

    yxMonths[9] = octName;

  }

  if (novName != "") {

    yxMonths[10] = novName;

  }

  if (decName != "") {

    yxMonths[11] = decName;

  }

}

 

function setDayNames(sunName, monName, tueName, wedName, thuName, friName, satName) {

  if (sunName != "") {

    yxDays[0] = sunName;

    yxDays[7] = sunName;

  }

  if (monName != "") {

    yxDays[1] = monName;

  }

  if (tueName != "") {

    yxDays[2] = tueName;

  }

  if (wedName != "") {

    yxDays[3] = wedName;

  }

  if (thuName != "") {

    yxDays[4] = thuName;

  }

  if (friName != "") {

    yxDays[5] = friName;

  }

  if (satName != "") {

    yxDays[6] = satName;

  }

}

 

function setLinkNames(closeLink, clearLink) {

  if (closeLink != "") {

    yxLinks[0] = closeLink;

  }

  if (clearLink != "") {

    yxLinks[1] = clearLink;

  }

}

 

function addCalendar(name, title, field, form) {

  cals[cals.length] = new calOBJ(name, title, field, form);

}

 

function findCalendar(name) {

  for (var i = 0; i < cals.length; i++) {

    if (cals[i].name == name) {

      if (cals[i].form == null) {

        if (cals[i].formName == "") {

          if (document.forms[0]) {

            cals[i].form = document.forms[0];

          }

        }

        else if (document.forms[cals[i].formName]) {

          cals[i].form = document.forms[cals[i].formName];

        }

      }

 

      return cals[i];

    }

  }

 

  return null;

}

 

function getDayName(y,m,d) {

  var wd=new Date(y,m,d);

  return yxDays[wd.getDay()].substring(0,3);

}

 

function getMonthFromName(m3) {

  for (var i = 0; i < yxMonths.length; i++) {

    if (yxMonths[i].toLowerCase().substring(0,3) == m3.toLowerCase()) {

      return i;

    }

  }

 

  return 0;

}

 

function getFormat() {

  var calF = calFormat;

 

  calF = calF.replace(/\\/g, '\\\\');

  calF = calF.replace(/\//g, '\\\/');

  calF = calF.replace(/\[/g, '\\\[');

  calF = calF.replace(/\]/g, '\\\]');

  calF = calF.replace(/\(/g, '\\\(');

  calF = calF.replace(/\)/g, '\\\)');

  calF = calF.replace(/\{/g, '\\\{');

  calF = calF.replace(/\}/g, '\\\}');

  calF = calF.replace(/\</g, '\\\<');

  calF = calF.replace(/\>/g, '\\\>');

  calF = calF.replace(/\|/g, '\\\|');

  calF = calF.replace(/\*/g, '\\\*');

  calF = calF.replace(/\?/g, '\\\?');

  calF = calF.replace(/\+/g, '\\\+');

  calF = calF.replace(/\^/g, '\\\^');

  calF = calF.replace(/\$/g, '\\\$');

 

  calF = calF.replace(/dd/i, '\\d\\d');

  calF = calF.replace(/mm/i, '\\d\\d');

  calF = calF.replace(/yyyy/i, '\\d\\d\\d\\d');

  calF = calF.replace(/day/i, '\\w\\w\\w');

  calF = calF.replace(/mon/i, '\\w\\w\\w');

 

  return new RegExp(calF);

}

 

function getDateNumbers(date) {

  var y, m, d;

 

  var yIdx = calFormat.search(/yyyy/i);

  var mIdx = calFormat.search(/mm/i);

  var m3Idx = calFormat.search(/mon/i);

  var dIdx = calFormat.search(/dd/i);

 

  y=date.substring(yIdx,yIdx+4)-0;

  if (mIdx != -1) {

    m=date.substring(mIdx,mIdx+2)-1;

  }

  else {

    var m = getMonthFromName(date.substring(m3Idx,m3Idx+3));

  }

  d=date.substring(dIdx,dIdx+2)-0;

 

  return new Array(y,m,d);

}

 

function hideCal() {

  calWin.close();

  calWin = null;

  window.status = "";

}

 

function getLeftIE(x,m) {

  var dx=0;

  if (x.tagName=="TD"){

    dx=x.offsetLeft;

  }

  else if (x.tagName=="TABLE") {

    dx=x.offsetLeft;

    if (m) { dx+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false; }

  }

  return dx+(x.parentElement.tagName=="BODY"?0:getLeftIE(x.parentElement,m));

}

function getTopIE(x,m) {

  var dy=0;

  if (x.tagName=="TR"){

    dy=x.offsetTop;

  }

  else if (x.tagName=="TABLE") {

    dy=x.offsetTop;

    if (m) { dy+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false; }

  }

  return dy+(x.parentElement.tagName=="BODY"?0:getTopIE(x.parentElement,m));

}

 

function getLeftN4(l) { return l.pageX; }

function getTopN4(l) { return l.pageY; }

 

function getLeftN6(l) { return l.offsetLeft; }

function getTopN6(l) { return l.offsetTop; }

 

function lastDay(d) {

  var yy=d.getFullYear(), mm=d.getMonth();

  for (var i=31; i>=28; i--) {

    var nd=new Date(yy,mm,i);

    if (mm == nd.getMonth()) {

      return i;

    }

  }

}

 

function firstDay(d) {

  var yy=d.getFullYear(), mm=d.getMonth();

  var fd=new Date(yy,mm,1);

  return fd.getDay();

}

 

function dayDisplay(i) {

  if (dayDigits == 0) {

    return yxDays[i];

  }

  else {

    return yxDays[i].substring(0,dayDigits);

  }

}

 

function calTitle(d) {

  var yy=d.getFullYear(), mm=yxMonths[d.getMonth()];

  var s;

 

  if (titleMode == 2) {

    s="<tr align='center' bgcolor='"+titleColor+"'><td colspan='7'>\n<table cellpadding='0' cellspacing='0' border='0'><tr align='center' valign='middle'><td align='right'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(-10)'> «</a> "+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(-1)'>‹ </a></b>"+span2+"</td><td width='"+titleWidth+"'><b>"+span1("title")+yy+span2+"</b></td><td align='left'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(1)'> ›</a> "+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(10)'>» </a></b>"+span2+"</td></tr><tr align='center' valign='middle'><td align='right'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.prepMonth) window.opener.prepMonth("+d.getMonth()+")'> ‹ </a></b>"+span2+"</td><td width='"+titleWidth+"'><b>"+span1("title")+mm+span2+"</b></td><td align='left'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.nextMonth) window.opener.nextMonth("+d.getMonth()+")'> › </a></b>"+span2+"</td></tr></table>\n</td></tr><tr align='center' bgcolor='"+daysColor+"'>";

  }

  else {

    s="<tr align='center' bgcolor='"+titleColor+"'><td colspan='7'>\n<table cellpadding='0' cellspacing='0' border='0'><tr align='center' valign='middle'><td>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(-1)'> «</a> "+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.prepMonth) window.opener.prepMonth("+d.getMonth()+")'>‹ </a></b>"+span2+"</td><td width='"+titleWidth+"'><nobr><b>"+span1("title")+mm+" "+yy+span2+"</b></nobr></td><td>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.nextMonth) window.opener.nextMonth("+d.getMonth()+")'> ›</a> "+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(1)'>» </a></b>"+span2+"</td></tr></table>\n</td></tr><tr align='center' bgcolor='"+daysColor+"'>";

  }

 

  for (var i=weekDay; i<weekDay+7; i++) {

    s+="<td width='"+dayWidth+"'>"+span1("days")+dayDisplay(i)+span2+"</td>";

  }

 

  s+="</tr>";

 

  return s;

}

 

function calHeader() {

  return "<head>\n<title>"+currentCal.title+"</title>\n<style type='text/css'>\n"+spanx("title",titleFontColor)+spanx("days",daysFontColor)+spanx("foot",footColor)+spanx("day",dayFontColor)+spanx("currentDay",currentDayFontColor)+ax("titlea",titleFontColor)+ax("daya",dayFontColor)+ax("currenta",currentDayFontColor)+ax("foota",footFontColor)+"</style>\n</head>\n<body>\n<table align='center' border='0' bgcolor='"+borderColor+"' cellspacing='0' cellpadding='1'><tr><td>\n<table cellspacing='1' cellpadding='3' border='0'>";

}

 

function calFooter() {

  return "<tr bgcolor='"+footColor+"'><td colspan='7' align='center'>"+span1("foot")+"<b>"+a1("foota")+"'javascript:if (window.opener && !window.opener.closed && window.opener.hideCal) window.opener.hideCal()'>"+yxLinks[0]+"</a>  "+a1("foota")+"'javascript:if (window.opener && !window.opener.closed && window.opener.clearDate) window.opener.clearDate()'>"+yxLinks[1]+"</a></b>"+span2+"</td></tr></table>\n</td></tr></table>\n</body>";

}

 

function calBody(d,day) {

  var s="", dayCount=1, fd=firstDay(d), ld=lastDay(d);

 

  if (weekDay > 0 && fd == 0) {

    fd = 7;

  }

 

  for (var i=0; i<6; i++) {

    s+="<tr align='center' bgcolor='"+bodyColor+"'>";

    for (var j=weekDay; j<weekDay+7; j++) {

      if (i*7+j<fd || dayCount>ld) {

        s+="<td>"+span1("day")+" "+span2+"</td>";

      }

      else {

        var bgColor=dayColor;

        var fgTag="day";

        var fgTagA="daya";

        if (dayCount==day) {

          bgColor=currentDayColor;

          fgTag="currentDay";

          fgTagA="currenta";

        }

       

        s+="<td bgcolor='"+bgColor+"'>"+span1(fgTag)+a1(fgTagA)+"'javascript: if (window.opener && !window.opener.closed && window.opener.pickDate) window.opener.pickDate("+dayCount+")'>"+(dayCount++)+"</a>"+span2+"</td>";

      }

    }

    s+="</tr>";

  }

 

  return s;

}

 

function moveYear(dy) {

  cY+=dy;

  var nd=new Date(cY,cM,1);

  changeCal(nd);

}

 

function prepMonth(m) {

  cM=m-1;

  if (cM<0) { cM=11; cY--; }

  var nd=new Date(cY,cM,1);

  changeCal(nd);

}

 

function nextMonth(m) {

  cM=m+1;

  if (cM>11) { cM=0; cY++;}

  var nd=new Date(cY,cM,1);

  changeCal(nd);

}

 

function changeCal(d) {

  var dd = 0;

 

  if (currentCal != null) {

    var calRE = getFormat();

 

    if (currentCal.form[currentCal.field].value!="" && calRE.test(currentCal.form[currentCal.field].value)) {

      var cd = getDateNumbers(currentCal.form[currentCal.field].value);

      if (cd[0] == d.getFullYear() && cd[1] == d.getMonth()) {

        dd=cd[2];

      }

    }

    else {

      var cd = new Date();

      if (cd.getFullYear() == d.getFullYear() && cd.getMonth() == d.getMonth()) {

        dd=cd.getDate();

      }

    }

  }

 

  var calendar=calHeader()+calTitle(d)+calBody(d,dd)+calFooter();

 

  calWin.document.open();

  calWin.document.write(calendar);

  calWin.document.close();

}

 

function markClick(e) {

  if (isIE || isOpera6) {

    winX=event.screenX;

    winY=event.screenY;

  }

  else if (isN4 || isN6) {

    winX=e.screenX;

    winY=e.screenY;

 

    document.routeEvent(e);

  }

 

  return true;

}

 

function showCal(name) {

  var lastCal=currentCal;

  var d=new Date(), hasCal=false;

 

  currentCal = findCalendar(name);

 

  if (currentCal != null && currentCal.form != null && currentCal.form[currentCal.field]) {

    var calRE = getFormat();

 

    if (currentCal.form[currentCal.field].value!="" && calRE.test(currentCal.form[currentCal.field].value)) {

      var cd = getDateNumbers(currentCal.form[currentCal.field].value);

      d=new Date(cd[0],cd[1],cd[2]);

 

      cY=cd[0];

      cM=cd[1];

      dd=cd[2];

    }

    else {

      cY=d.getFullYear();

      cM=d.getMonth();

      dd=d.getDate();

    }

 

    var calendar=calHeader()+calTitle(d)+calBody(d,dd)+calFooter();

 

    if (calWin != null && !calWin.closed) {

      hasCal=true;

      calWin.moveTo(winX+calOffsetX,winY+calOffsetY);

    }

 

    if (!hasCal) {

      if (isIE || isOpera6) {

        calWin=window.open("","cal","toolbar=0,width="+calWidth+",height="+calHeight+",left="+(winX+calOffsetX)+",top="+(winY+calOffsetY));

      }

      else {

        calWin=window.open("","cal","toolbar=0,width="+calWidth+",height="+calHeight+",screenx="+(winX+calOffsetX)+",screeny="+(winY+calOffsetY));

      }

    }

 

    calWin.document.open();

    calWin.document.write(calendar);

    calWin.document.close();

 

    calWin.focus();

  }

  else {

    if (currentCal == null) {

      window.status = "Calendar ["+name+"] not found.";

    }

    else if (!currentCal.form) {

      window.status = "Form ["+currentCal.formName+"] not found.";

    }

    else if (!currentCal.form[currentCal.field]) {

      window.status = "Form Field ["+currentCal.formName+"."+currentCal.field+"] not found.";

    }

 

    if (lastCal != null) {

      currentCal = lastCal;

    }

  }

}

 

function get2Digits(n) {

  return ((n<10)?"0":"")+n;

}

 

function clearDate() {

  currentCal.form[currentCal.field].value="";

  hideCal();

}

 

function pickDate(d) {

  hideCal();

  window.focus();

 

  var date=calFormat;

  date = date.replace(/yyyy/i, cY);

  date = date.replace(/mm/i, get2Digits(cM+1));

  date = date.replace(/MON/, yxMonths[cM].substring(0,3).toUpperCase());

  date = date.replace(/Mon/i, yxMonths[cM].substring(0,3));

  date = date.replace(/dd/i, get2Digits(d));

  date = date.replace(/DAY/, getDayName(cY,cM,d).toUpperCase());

  date = date.replace(/day/i, getDayName(cY,cM,d));

 

  currentCal.form[currentCal.field].value=date;

  // IE5/Mac needs focus to show the value, weird.

  currentCal.form[currentCal.field].focus();

}

// ------

 

// user functions

function checkDate(name) {

  var thisCal = findCalendar(name);

 

  if (thisCal != null && thisCal.form != null && thisCal.form[thisCal.field]) {

    var calRE = getFormat();

 

    if (calRE.test(thisCal.form[thisCal.field].value)) {

      return 0;

    }

    else {

      return 1;

    }

  }

  else {

    return 2;

  }

}

 

function getCurrentDate() {

  var date=calFormat, d = new Date();

  date = date.replace(/yyyy/i, d.getFullYear());

  date = date.replace(/mm/i, get2Digits(d.getMonth()+1));

  date = date.replace(/dd/i, get2Digits(d.getDate()));

 

  return date;

}

 

function compareDates(date1, date2) {

  var calRE = getFormat();

  var d1, d2;

 

  if (calRE.test(date1)) {

    d1 = getNumbers(date1);

  }

  else {

    d1 = getNumbers(getCurrentDate());

  }

 

  if (calRE.test(date2)) {

    d2 = getNumbers(date2);

  }

  else {

    d2 = getNumbers(getCurrentDate());

  }

 

  var dStr1 = d1[0] + "" + d1[1] + "" + d1[2];

  var dStr2 = d2[0] + "" + d2[1] + "" + d2[2];

 

  if (dStr1 == dStr2) {

    return 0;

  }

  else if (dStr1 > dStr2) {

    return 1;

  }

  else {

    return -1;

  }

}

 

function getNumbers(date) {

  var calRE = getFormat();

  var y, m, d;

 

  if (calRE.test(date)) {

    var yIdx = calFormat.search(/yyyy/i);

    var mIdx = calFormat.search(/mm/i);

    var m3Idx = calFormat.search(/mon/i);

    var dIdx = calFormat.search(/dd/i);

 

    y=date.substring(yIdx,yIdx+4);

    if (mIdx != -1) {

      m=date.substring(mIdx,mIdx+2);

    }

    else {

      var mm=getMonthFromName(date.substring(m3Idx,m3Idx+3))+1;

      m=(mm<10)?("0"+mm):(""+mm);

    }

    d=date.substring(dIdx,dIdx+2);

 

    return new Array(y,m,d);

  }

  else {

    return new Array("", "", "");

  }

}

// ------

 

if (isN4 || isN6) {

  document.captureEvents(Event.CLICK);

}

document.onclick=markClick;

 

</script>

<script language="javascript">

 

//Define calendar(s): addCalendar ("Unique Calendar Name", "Window title", "Form element's name", Form name")

addCalendar("Calendar1", "Select Date", "firstinput", "sampleform");

addCalendar("Calendar2", "Select Date", "secondinput", "sampleform");

 

// default settings for English

// Uncomment desired lines and modify its values

// setFont("verdana", 9);

 setWidth(90, 1, 15, 1);

// setColor("#cccccc", "#cccccc", "#ffffff", "#ffffff", "#333333", "#cccccc", "#333333");

// setFontColor("#333333", "#333333", "#333333", "#ffffff", "#333333");

// setFormat("yyyy/mm/dd");

// setSize(200, 200, -200, 16);

 

// setWeekDay(0);

// setMonthNames("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

// setDayNames("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

// setLinkNames("[Close]", "[Clear]");

</script>

<form name="sampleform">

<input type="text" name="firstinput" size=20> <small><a href="javascript:showCal('Calendar1')">选择日期一</a></small>

<p><input type="text" name="secondinput" size=20> <small><a href="javascript:showCal('Calendar2')">选择日期二</a></small>

</form>

 

0 Comments

Wed

18

Mar

2009

58、最简单倒计时

58、最简单倒计时

脚本说明:

把如下代码加入<body>区域中

<Script Language="JavaScript">

<!-- Begin

  var timedate= new Date("October 1,2006");

  var times="国庆节";

  var now = new Date();

  var date = timedate.getTime() - now.getTime();

  var time = Math.floor(date / (1000 * 60 * 60 * 24));

  if (time >= 0) ;

document.write("现在离2006"+times+"还有: <font color=red><b>"+time +"</b></font>");

// End -->

</Script>

 

0 Comments

Wed

18

Mar

2009

57、下拉框显示当前时间

57、下拉框显示当前时间

脚本说明:

把如下代码加入<body>区域中

<script language="javascript">

function nowtime()

{

       var da,ny,nm,nd;

       da = new Date();

       ny = da.getYear();

       nm = da.getMonth();

       nd = da.getDate();

       document.form1.year2.value = ny;

       document.form1.month2.value = nm+1;

       document.form1.day2.value = nd;

}

</script>

    <form name="form1" method="post" action="#">

      <table width="100%" border="0" cellspacing="0" cellpadding="0">

      

        <tr>

          <td height="30">

            <select name="year2" >

              <option value="2002">2002</option>

              <option value="2003">2003</option>

              <option value="2004">2004</option>

                       <option value="2005">2005</option>

              <option value="2006">2006</option>

              <option value="2007">2007</option>

                       <option value="2008">2008</option>

              <option value="2009">2009</option>

              <option value="2010">2010</option>

            </select>

           

            <select name="month2">

              <option value="1">1</option>

              <option value="2">2</option>

              <option value="3">3</option>

              <option value="4">4</option>

              <option value="5">5</option>

              <option value="6">6</option>

              <option value="7">7</option>

              <option value="8">8</option>

              <option value="9">9</option>

              <option value="10">10</option>

              <option value="11">11</option>

              <option value="12">12</option>

            </select>

           

            <select name="day2">

              <option value="1">1</option>

              <option value="2" >2</option>

              <option value="3" >3</option>

              <option value="4" >4</option>

              <option value="5" >5</option>

              <option value="6" >6</option>

              <option value="7" >7</option>

              <option value="8" >8</option>

              <option value="9" >9</option>

              <option value="10" >10</option>

              <option value="11" >11</option>

              <option value="12" >12</option>

              <option value="13" >13</option>

              <option value="14" >14</option>

              <option value="15" >15</option>

              <option value="16" >16</option>

              <option value="17" >17</option>

              <option value="18" >18</option>

              <option value="19" >19</option>

              <option value="20" >20</option>

              <option value="21" >21</option>

              <option value="22" >22</option>

              <option value="23" >23</option>

              <option value="24" >24</option>

              <option value="25" >25</option>

              <option value="26" >26</option>

              <option value="27" >27</option>

              <option value="28" >28</option>

              <option value="29" >29</option>

              <option value="30" >30</option>

              <option value="31" >31</option>

            </select>

            

            <script language="Javascript">

                           if (this.form1.month2!="")

                            {nowtime()}

                       </script>

                     </td>

        </tr>

      

      </table>

         </form>

 

0 Comments

Wed

18

Mar

2009

56、最简单时间显示

56、最简单时间显示

脚本说明:

把如下代码加入<body>区域中

<div id="jnkc">

</div>

<script>setInterval("jnkc.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);

</script>

 

0 Comments

Wed

18

Mar

2009

55、选择时间计算星期几

55、选择时间计算星期几

脚本说明:

把如下代码加入<body>区域中

<form>

<select id=year onchange=toDate()>

<script>for(i=1970;i<=2010;i++)document.write("<option>"+i+"</option>")</script>

</select>

<select id=month onchange=toDate()>

<script>for(i=1;i<=12;i++)document.write("<option>"+i+"</option>")</script>

</select>

<select id=day onchange=toDay()></select>

<input name=weekday>

</form>

<script>

var arr="日一二三四五六".split("")

 

function toDate(){

       with(document.all){

              vYear=parseInt(year.options[year.selectedIndex].text)

              vMonth=parseInt(month.options[month.selectedIndex].text)

              day.length=0;

              for(i=0;i<(new Date(vYear,vMonth,0)).getDate();i++){day.options[day.length++].value=day.length;day.options[day.length-1].text=day.length;}

       }

       toDay();

}

 

function toDay(){

       vDay=parseInt(document.all.day.options[document.all.day.selectedIndex].value)

       document.all("weekday").value="星期"+arr[new Date(vYear,vMonth-1,vDay).getDay()]

}

 

window.onload=toDate;

</script>

 

0 Comments

Wed

18

Mar

2009

54、出现不同的提示信息,

54、出现不同的提示信息

脚本说明:

把如下代码加入<body>区域中

<SCRIPT>

today=new Date();

var day; var date; var hello; var wel;

hour=new Date().getHours()

if(hour < 6)hello='凌晨好'

else if(hour < 9)hello='早上好'

else if(hour < 12)hello='上午好'

else if(hour < 14)hello='中午好'

else if(hour < 17)hello='下午好'

else if(hour < 19)hello='傍晚好'

else if(hour < 22)hello='晚上好'

else {hello='夜里好!'}

if(today.getDay()==0)day='星期日'

else if(today.getDay()==1)day='星期一'

else if(today.getDay()==2)day='星期二'

else if(today.getDay()==3)day='星期三'

else if(today.getDay()==4)day='星期四'

else if(today.getDay()==5)day='星期五'

else if(today.getDay()==6)day='星期六'

date=(today.getYear())+''+(today.getMonth() + 1 )+''+today.getDate()+'';

if(hour<1)wel='子时';

else if(hour<3)wel='丑时';

else if(hour<5)wel='寅时';

else if(hour<7)wel='卯时';

else if(hour<9)wel='辰时';

else if(hour<11)wel='巳时';

else if(hour<13)wel='午时';

else if(hour<15)wel='未时';

else if(hour<17)wel='申时';

else if(hour<19)wel='酉时';

else if(hour<21)wel='戌时';

else if(hour<23)wel='亥时';

else {wel='子时';}

document.write(hello);

</SCRIPT> 现在是<SCRIPT>

document.write(date + ' ' + day + ' ' + wel);

    </SCRIPT>

 

0 Comments

Wed

18

Mar

2009

53、点击按钮展开时间选择表

53、点击按钮展开时间选择表

脚本说明:

把如下代码加入<body>区域中

              <script language='javascript' src="071701/popcalendar.js"></script>

 

              <SCRIPT LANGUAGE="JavaScript" SRC="071701/lw_layers.js"></SCRIPT>

 

             <SCRIPT LANGUAGE="JavaScript" SRC="071701/lw_menu.js"></SCRIPT>

                            <B><U>示例一</U></B><BR><BR>

<blockquote>

 

                                   <form name='mainform' method='post'>

 

                                          <input type=text name='datevalue' size=10 maxlength=10 value='02/02/2002'>

 

                                          <script language='javascript'>

 

                                          <!--

 

                                                 if (!document.layers) {

 

                                                        document.write("<input type=button onclick='popUpCalendar(this, mainform.datevalue, \"dd/mm/yyyy\")' value='请选择' style='font-size:11px'>")

 

                                                 }

 

                                          //-->

 

                                          </script>                            

 

                                   </form>

 

                                   </blockquote><BR><BR>

 

                            <B><U>示例二</U></B><BR><BR>

 

                                   <input style='font-size:11px' type=button value="2 December 2001" onclick='popUpCalendar(this, this, "d mmm yyyy")'>

 

                                   </blockquote><BR>

 

0 Comments

Wed

18

Mar

2009

52、很漂亮实用的日历

52、很漂亮实用的日历

<html>

 

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>网页特效---一个很漂亮实用的日历</title>

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

//创建一个数组,用于存放每个月的天数

function montharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11)

{

this[0] = m0;

this[1] = m1;

this[2] = m2;

this[3] = m3;

this[4] = m4;

this[5] = m5;

this[6] = m6;

this[7] = m7;

this[8] = m8;

this[9] = m9;

this[10] = m10;

this[11] = m11;

}

//实现月历

function calendar() {

var monthNames = "JanFebMarAprMayJunJulAugSepOctNovDec";

var today = new Date();

var thisDay;

var monthDays = new montharr(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

year = today.getYear() +1900;

thisDay = today.getDate();

if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monthDays[1] = 29;

nDays = monthDays[today.getMonth()];

firstDay = today;

firstDay.setDate(1);

testMe = firstDay.getDate();

if (testMe == 2) firstDay.setDate(0);

startDay = firstDay.getDay();

document.write("<div id='rili' style='position:absolute;width:140px;left:300px;top:100px;'>")

document.write("<TABLE width='217' BORDER='0' CELLSPACING='0' CELLPADDING='2' BGCOLOR='#0080FF'>")

document.write("<TR><TD><table border='0' cellspacing='1' cellpadding='2' bgcolor='Silver'>");

document.write("<TR><th colspan='7' bgcolor='#C8E3FF'>");

var dayNames = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");

var monthNames = new Array("1","2","3","4","5","6","7","8","9","10","11","12");

var now = new Date();

document.writeln("<FONT STYLE='font-size:9pt;Color:#330099'>" + "公元 " + now.getYear() + "" + monthNames[now.getMonth()] + " " + now.getDate() + " " + dayNames[now.getDay()] + "</FONT>");

document.writeln("</TH></TR><TR><TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'></FONT></TH>");

document.writeln("<th bgcolor='#0080FF'><FONT STYLE='font-size:9pt;Color:White'></FONT></TH>");

document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'></FONT></TH>");

document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'></FONT></TH>");

document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'></FONT></TH>");

document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'></FONT></TH>");

document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'></FONT></TH>");

document.writeln("</TR><TR>");

column = 0;

for (i=0; i<startDay; i++) {

document.writeln("\n<TD><FONT STYLE='font-size:9pt'> </FONT></TD>");

column++;

}

 

for (i=1; i<=nDays; i++) {

if (i == thisDay) {

document.writeln("</TD><TD ALIGN='CENTER' BGCOLOR='#FF8040'><FONT STYLE='font-size:9pt;Color:#ffffff'><B>")

}

else {

document.writeln("</TD><TD BGCOLOR='#FFFFFF' ALIGN='CENTER'><FONT STYLE='font-size:9pt;font-family:Arial;font-weight:bold;Color:#330066'>");

}

document.writeln(i);

if (i == thisDay) document.writeln("</FONT></TD>")

column++;

if (column == 7) {

document.writeln("<TR>");

column = 0;

}

}

document.writeln("<TR><TD COLSPAN='7' ALIGN='CENTER' VALIGN='TOP' BGCOLOR='#0080FF'>")

document.writeln("<FORM NAME='clock' onSubmit='0'><FONT STYLE='font-size:9pt;Color:#ffffff'>")

document.writeln("现在时间:<INPUT TYPE='Text' NAME='face' ALIGN='TOP'></FONT></FORM></TD></TR></TABLE>")

document.writeln("</TD></TR></TABLE></div>");

}

</SCRIPT>

<SCRIPT LANGUAGE="JavaScript">

var timerID = null;

var timerRunning = false;

 

function stopclock (){

if(timerRunning)

clearTimeout(timerID);

timerRunning = false;}

 

//显示当前时间

function showtime () {

var now = new Date();

var hours = now.getHours();

var minutes = now.getMinutes();

var seconds = now.getSeconds()

var timeValue = " " + ((hours >12) ? hours -12 :hours)

timeValue += ((minutes < 10) ? ":0" : ":") + minutes

timeValue += ((seconds < 10) ? ":0" : ":") + seconds

timeValue += (hours >= 12) ? " 下午 " : " 上午 "

document.clock.face.value = timeValue;

timerID = setTimeout("showtime()",1000);//设置超时,使时间动态显示

timerRunning = true;}

 

function startclock () {

stopclock();

showtime();}

</SCRIPT>

</head>

 

<body onLoad="startclock(); timerONE=window.setTimeout">

 

<script language="JavaScript" type="text/javascript">

<!--

calendar();

//-->

 

</script>

 

</body>

 

</html>

 

 

0 Comments

Wed

18

Mar

2009

51、显示来访者登陆时间代码

51、显示来访者登陆时间代码

脚本说明:

 

把如下代码加入<body>区域中

 

<form name=forms> <font size=3><CENTER><div align=center><p></font><font color=red size=3>您在本站逗留了</font><font color=#80FF80><br> <input type=text name=input1 size=10></font></p></div></center></font><SCRIPT language=javascript><!--

 

 

 

var sec=0;var min=0;var hou=0;flag=0;idt=window.setTimeout("update();",1000);function update(){sec++;if(sec==60){sec=0;min+=1;}if(min==60){min=0;hou+=1;}if((min>0)&&(flag==0)){window.alert("您刚刚来了1分钟!可别急着走开,还有好多好东东等着您呢!--站长");flag=1;}

 

 

 

document.forms.input1.value=hou+""+min+""+sec+"";idt=window.setTimeout("update();",1000);}

 

//-->

 

 

 

</SCRIPT></form>

 

 

0 Comments

Wed

18

Mar

2009

50、简单的全日制 时间代码

50、简单的全日制 时间代码

<div id="linkweb">

</div>

<script>setInterval("linkweb.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);

</script>

 

 

0 Comments

Wed

18

Mar

2009

49、输入日期选择效果

49、输入日期选择效果

<HTML><HEAD><TITLE>添加日期</TITLE>

<META http-equiv=Content-Type content="text/html; charset=gb2312">

<STYLE type=text/css>BODY {

 BACKGROUND-COLOR: #d4d0c8

}

.c_fieldset {

 PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 5px; WIDTH: 180px; PADDING-TOP: 0px; TEXT-ALIGN: center

}

.c_legend {

 FONT-SIZE: 11px; PADDING-BOTTOM: 5px; FONT-FAMILY: Tahoma

}

.c_frameborder {

 BORDER-RIGHT: #ffffff 2px inset; BORDER-TOP: #d4d0c8 2px inset; FONT-SIZE: 10px; OVERFLOW: hidden; BORDER-LEFT: #d4d0c8 2px inset; WIDTH: 160px; BORDER-BOTTOM: #ffffff 2px inset; FONT-FAMILY: "Tahoma"; HEIGHT: 120px; BACKGROUND-COLOR: #ffffff

}

.c_frameborder TD {

 FONT-SIZE: 11px; WIDTH: 23px; CURSOR: default; FONT-FAMILY: "Tahoma"; HEIGHT: 16px; TEXT-ALIGN: center

}

.c_frameborder .selected {

 COLOR: white; BACKGROUND-COLOR: #0a246a

}

.c_frameborder SPAN {

 WIDTH: 12px; HEIGHT: 12px

}

.c_arrow {

 PADDING-LEFT: 2px; FONT-SIZE: 7px; WIDTH: 16px; CURSOR: default; LINE-HEIGHT: 2px; FONT-FAMILY: "Webdings"; HEIGHT: 8px

}

.c_year {

 FONT-SIZE: 11px; WIDTH: 55px; CURSOR: default; FONT-FAMILY: "Tahoma"; HEIGHT: 19px

}

.c_month {

 FONT: 11px "Tahoma"; WIDTH: 75px; HEIGHT: 20px

}

.c_dateHead {

 COLOR: #d4d0c8; BACKGROUND-COLOR: #808080

}

</STYLE>

 

<SCRIPT language=javascript>

// Written by cloudchen, 2004/03/16

function calendar(name,fName)

{

    var calendar=this

 this.name = name;

 this.fName = fName || "calendar";

 this.year = new Date().getFullYear();

 this.month = new Date().getMonth();

 this.date = new Date().getDate();

 //private

 this.toString = function()

 {

  var str = "";

  str += "<table border=\"0\" cellspacing=\"3\" cellpadding=\"0\" onselectstart=\"return false\">";

  str += "<tr>";

  str += "<td>";

  str += this.drawMonth();

  str += "</td>";

  str += "<td align=\"right\">";

  str += this.drawYear();

  str += "</td>";

  str += "</tr>";

  str += "<tr>";

  str += "<td colspan=\"2\">";

  str += "<div class=\"c_frameborder\">";

  str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"c_dateHead\">";

  str += "<tr>";

  str += "<td></td><td></td><td></td><td></td><td></td><td></td><td></td>";

  str += "</tr>";

  str += "</table>";

  str += this.drawDate();

  str += "</div>";

  str += "</td>";

  str += "</tr>";

  str += "</table>";

  return str;

 }

 //private

 this.drawYear = function()

 {

  var str = "";

  str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";

  str += "<tr>";

  str += "<td>";

  str += "<input class=\"c_year\" maxlength=\"4\" value=\""+this.year+"\" name=\""+this.fName+"\" id=\""+this.fName+"_year\" readonly>";

  //DateField

  str += "<input type=\"hidden\" name=\""+this.fName+"\" value=\""+this.date+"\" id=\""+this.fName+"_date\">";

  str += "</td>";

  str += "<td>";

  str += "<table cellspacing=\"2\" cellpadding=\"0\" border=\"0\">";

  str += "<tr>";

  str += "<td><button class=\"c_arrow\" onfocus=\"this.blur()\" onclick=\"event.cancelBubble=true;document.getElementById('"+this.fName+"_year').value++;"+this.name+".redrawDate()\">5</button></td>";

  str += "</tr>";

  str += "<tr>";

  str += "<td><button class=\"c_arrow\" onfocus=\"this.blur()\" onclick=\"event.cancelBubble=true;document.getElementById('"+this.fName+"_year').value--;"+this.name+".redrawDate()\">6</button></td>";

  str += "</tr>";

  str += "</table>";

  str += "</td>";

  str += "</tr>";

  str += "</table>";

  return str;

 }

 //priavate

 this.drawMonth = function()

 {

  var aMonthName = ["","","","","","","","","","","十一","十二"];

  var str = "";

  str += "<select class=\"c_month\" name=\""+this.fName+"\" id=\""+this.fName+"_month\" onchange=\""+this.name+".redrawDate()\">";

  for (var i=0;i<aMonthName.length;i++) {

   str += "<option value=\""+(i+1)+"\" "+(i==this.month?"selected":"")+">"+aMonthName[i]+"</option>";

  }

  str += "</select>";

  return str;

 }

 //private

 this.drawDate = function()

 {

  var str = "";

  var fDay = new Date(this.year,this.month,1).getDay();

  var fDate = 1-fDay;

  var lDay = new Date(this.year,this.month+1,0).getDay();

  var lDate = new Date(this.year,this.month+1,0).getDate();

  str += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\""+this.fName+"_dateTable"+"\">";

  for (var i=1,j=fDate;i<7;i++)

  {

   str += "<tr>";

   for (var k=0;k<7;k++)

   {

    str += "<td style='cursor:hand'><span"+(j==this.date?" class=\"selected\"":"")+" onclick=\""+this.name+".redrawDate(this.innerText,1)\" onmouseover=\"this.style.border='1px solid #333333'\" onmouseout=\"this.style.border=''\" style=\"width:15px;height:13px;padding-left:1px\">"+(isDate(j++))+"</td>";

   }

   str += "</tr>";

  }

  str += "</table>";

  return str;

 

  function isDate(n)

  {

   return (n>=1&&n<=lDate)?n:"";

  }

 }

 //public

 this.redrawDate = function(d,type)

 {

  this.year = document.getElementById(this.fName+"_year").value;

  this.month = document.getElementById(this.fName+"_month").value-1;

  this.date = d || this.date;

  var c=1

  document.getElementById(this.fName+"_year").value = this.year;

  document.getElementById(this.fName+"_month").selectedIndex = this.month;

  document.getElementById(this.fName+"_date").value = this.date;

  if (this.date>new Date(this.year,this.month+1,0).getDate()) this.date = new Date(this.year,this.month+1,0).getDate();

  document.getElementById(this.fName+"_dateTable").outerHTML = this.drawDate();

  if (type==1 && d) sendTo(calendar.getDate())

 }

 //public

 this.getDate = function(delimiter)

 {

  if (!delimiter) delimiter = "-";

  var aValue = [this.year,(this.month+1),this.date];

  return aValue.join(delimiter);

 }

}

 

function sendTo(dvalue)

{

  if (!dvalue)

    {window.returnValue =""}

  else

    {window.returnValue = dvalue}

  window.close()

}

</SCRIPT>

 

</HEAD>

<BODY>

<DIV align=center>

<TABLE width=180 border=0>

  <TBODY>

  <TR>

    <TD>

      <FIELDSET class=c_fieldset><LEGEND class=c_legend>日期</LEGEND><!-- 调用日历 -->

      <SCRIPT>

var c = new calendar("c");

document.write(c);

</SCRIPT>

<!-- 调用日历 --></FIELDSET> </TD></TR>

  <TR>

    <TD align=right><BUTTON

      style="BORDER-RIGHT: 1px outset; BORDER-TOP: 1px outset; FONT-SIZE: 12px; BORDER-LEFT: 1px outset; BORDER-BOTTOM: 1px outset"

      onclick=sendTo(c.getDate())>确定</BUTTON>  <BUTTON

      style="BORDER-RIGHT: 1px outset; BORDER-TOP: 1px outset; FONT-SIZE: 12px; BORDER-LEFT: 1px outset; BORDER-BOTTOM: 1px outset"

      onclick="sendTo('null')">清除</BUTTON>  <BUTTON

      style="BORDER-RIGHT: 1px outset; BORDER-TOP: 1px outset; FONT-SIZE: 12px; BORDER-LEFT: 1px outset; BORDER-BOTTOM: 1px outset"

      onclick=window.close()>取消</BUTTON>

</TD></TR></TBODY></TABLE></DIV></BODY></HTML>

 

0 Comments

Wed

18

Mar

2009

48、非常不错的日期选择风格

48、非常不错的日期选择风格

<html>

 

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>网页特效---非常不错的日期选择风格</title>

</head>

 

<body>

 

<style type="text/css">

.body,td{

font-family:"Arial";

font-size:8pt;

color:#000000;

}

.TrOut{

background:#dddddd;

height:24;

border:1 solid #999999;

border-top-color:#f4f4f4;

border-left-color:#f4f4f4;

}

.TdOver{

background:#eeeeee;

height:20;

border:1 solid #ffffff;

border-top-color:#9c9c9c;

border-left-color:#9c9c9c;

}

.TdOut{

background:#eeeeee;

height:20;

border:1 solid #9c9c9c;

border-top-color:#ffffff;

border-left-color:#ffffff;

}

</style>

<script language="JScript">

function TableFunction(){

        this.GetDataStr=function(y,m){

                this.DayArray=[];

                for(var i=0;i<42;i++)this.DayArray[i]=" ";

                for(var i=0;i<new Date(y,m,0).getDate();i++)this.DayArray[i+new Date(y,m-1,1).getDay()]=i+1;

                return this.DayArray;

                }

        this.GetTableStr=function(y,m){

                this.DateArray=["","","","","","",""];

                this.DStr="<table oncontextmenu='return false' onselectstart='return false' style='width:160;cursor:default;border:1 solid #9c9c9c;border-right:0;border-bottom:0;filter:progid:dximagetransform.microsoft.dropshadow(color=#e3e3e3,offx=3,offy=3,positive=true)' border='0' cellpadding='0' cellspacing='0'>\n"+

                "<tr><td colspan='7' class='TrOut'>"+

                "<table width='100%' height='100%'border='0' cellpadding='0' cellspacing='0'><tr align='center'>\n"+

                "<td width='20' style='font-family:\"webdings\";font-size:9pt' onclick='TableFunction().JumpToRun(\"b\")' onmouseover='this.style.color=\"#ff9900\"' onmouseout='this.style.color=\"\"'>3</td>\n"+

                "<td id='YearTD' width='70' onmouseover='this.style.background=\"#cccccc\"' onmouseout='this.style.background=\"\"' onclick='TableFunction().WriteSelect(this,this.innerText.split(\" \")[0],\"y\",false)'>"+y+" </td>\n"+

                "<td id='MonthTD' width='47' onmouseover='this.style.background=\"#cccccc\"' onmouseout='this.style.background=\"\"' onclick='TableFunction().WriteSelect(this,this.innerText.split(\" \")[0],\"m\",false)'>"+m+" </td>\n"+

                "<td width='20' style='font-family:\"webdings\";font-size:9pt' onclick='TableFunction().JumpToRun(\"n\")' onmouseover='this.style.color=\"#ff9900\"' onmouseout='this.style.color=\"\"'>4</td></tr></table>\n"+

                "</td></tr>\n"+

                "<tr align='center'>\n";

                for(var i=0;i<7;i++)

                this.DStr+="<td class='TrOut'>"+DateArray[i]+"</td>\n";

                this.DStr+="</tr>\n";

                for(var i=0;i<6;i++){

                this.DStr+="<tr align='center'>\n";

                for(var j=0;j<7;j++){

                        var CS=new Date().getDate()==this.GetDataStr(y,m)[i*7+j]?"TdOver":"TdOut";

                        this.DStr+="<td id='TD' class='"+CS+"' cs='"+CS+"' onmouseover='this.className=\"TdOver\"' onmouseout='if(this.cs!=\"TdOver\")this.className=\"TdOut\"'>"+this.GetDataStr(y,m)[i*7+j]+"</td>\n";

                        }

                this.DStr+="</tr>\n";

                }

                this.DStr+="</tabe>";

                return this.DStr;

                }

        this.WriteSelect=function(obj,values,action,getobj){

                if(values=="")return;

                if(getobj){

                        obj.innerHTML=values+(action=="y"?" ":" ");

                        this.RewriteTableStr(YearTD.innerText.split(" ")[0],MonthTD.innerText.split(" ")[0]);

                        return false;

                        }

                var StrArray=[];

                if(action=="y"){

                        for(var i=0;i<15;i++){

                                var year=values-7+i;

                                StrArray[i]="<option value='"+year+"' "+(values==year?"selected":"")+"> "+year+"</option>\n";

                                }

                        obj.innerHTML="<select id='select1' onchange='TableFunction().WriteSelect(parentElement,this.value,\"y\",true)' onblur='YearTD.innerText=this.value+\" \"'>\n"+StrArray.join("")+"</select>";

                        select1.focus();

                        }

                if(action=="m"){

                        for(var i=1;i<13;i++)

                                StrArray[i]="<option value='"+i+"' "+(i==values?"selected":"")+"> "+i+"</option>\n";

                        obj.innerHTML="<select id='select2' style='width:47' onchange='TableFunction().WriteSelect(parentElement,this.value,\"m\",true)' onblur='MonthTD.innerText=this.value+\" \"'>\n"+StrArray.join("")+"</select>";

                        select2.focus();

                        }

                }

        this.RewriteTableStr=function(y,m){

                var TArray=this.GetDataStr(y,m);

                for(var i=0;i<TArray.length;i++){

                        TD[i].innerHTML=TArray[i];

                        TD[i].className="TdOut";

                        TD[i].cs="TdOut";

                        if(new Date().getYear()==y&&new Date().getMonth()+1==m&&TArray[i]==new Date().getDate()){

                                TD[i].className="TdOver";

                                TD[i].cs="TdOver";

                                }

                        }

                }

        this.JumpToRun=function(action){

                var YearNO=YearTD.innerText.split(' ')[0];

                var MonthNO=MonthTD.innerText.split(' ')[0];

                if(action=="b"){

                        if(MonthNO=="1"){

                                MonthNO=13;

                                YearNO=YearNO-1;

                                }

                        MonthTD.innerText=MonthNO-1+" ";

                        YearTD.innerText=YearNO+" ";

                        this.RewriteTableStr(YearNO,MonthNO-1);

                        }

                if(action=="n"){

                        if(MonthNO=="12"){

                                MonthNO=0;

                                YearNO=YearNO-(-1);

                                }

                        YearTD.innerText=YearNO+" ";

                        MonthTD.innerText=MonthNO-(-1)+" ";

                        this.RewriteTableStr(YearNO,MonthNO-(-1));

                        }

                }

        return this;

        }

document.write(TableFunction().GetTableStr(new Date().getYear(),new Date().getMonth()+1));

</script>

 

</body>

 

</html>

 

0 Comments

Wed

18

Mar

2009

47、年月日时分秒的即时显示

47、年月日时分秒的即时显示

<html>

 

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>网页特效观止--年月日时分秒的即时显示</title>

 

</head>

 

<body onload=startclock()>

 

<form name="clock">

<script language="JavaScript">

var timerID = null;

var timerRunning = false;

function stopclock (){

if(timerRunning)

clearTimeout(timerID);

timerRunning = false;}

function startclock () {

stopclock();

showtime();}

function showtime () {

var now = new Date();

var hours = now.getHours();

var minutes = now.getMinutes();

var seconds = now.getSeconds()

var timeValue = now.getYear()+""+(now.getMonth()+1)+""+now.getDate()+"" +((hours >= 12) ? " 下午 " : " 上午 " )

timeValue += ((hours >12) ? hours -12 :hours)

timeValue += ((minutes < 10) ? ":0" : ":") + minutes

timeValue += ((seconds < 10) ? ":0" : ":") + seconds

document.clock.thetime.value = timeValue;

timerID = setTimeout("showtime()",1000);

timerRunning = true;}

</script>

<input name="thetime" style="font-size: 9pt;color:#000000;border:1px solid #FFFFFF; ; " size="28"></form>

 

</body>

</html>

 

0 Comments

Wed

18

Mar

2009

46、全中文日期显示

46、全中文日期显示

脚本说明:

把如下代码加入<body>区域中:

<script language="JavaScript">

function number(index1){

var numberstring="一二三四五六七八九十";

  if(index1 ==0) {document.write("")}

  if(index1 < 10){

    document.write(numberstring.substring(0+(index1-1),index1))}

  else if(index1 < 20 ){

    document.write(""+numberstring.substring(0+(index1-11),(index1-10)))}

  else if(index1 < 30 ){

    document.write("二十"+numberstring.substring(0+(index1-21),(index1-20)))}

  else{

    document.write("三十"+numberstring.substring(0+(index1-31),(index1-30)))}

  }

 

var today1 = new Date()

var month = today1.getMonth()+1

var date = today1.getDate()

var day = today1.getDay()

 

document.write("公元二零零零年")

number(month)

document.write("")

number(date)

document.write("")

</script>

 

0 Comments

Wed

18

Mar

2009

45、八种风格时间日期

45、八种风格时间日期

脚本说明:

第一步:把如下代码加入<head>区域中

<SCRIPT language=javascript author=luxiaoqing><!--

function initArray(){for(i=0;i<initArray.arguments.length;i++)

this[i]=initArray.arguments[i];}var isnMonths=new initArray("1","2","3","4","5","6","7","8","9","10","11","12");var isnDays=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六","星期日");today=new Date();hrs=today.getHours();min=today.getMinutes();sec=today.getSeconds();clckh=""+((hrs>12)?hrs-12:hrs);

clckm=((min<10)?"0":"")+min;clcks=((sec<10)?"0":"")+sec;clck=(hrs>=12)?"下午":"上午";var stnr="";var ns="0123456789";var a="";

 

//-->

 

</SCRIPT>

第二步:把如下代码加入区域中

<SCRIPT language=javascript><!--

function getFullYear(d){//d is a date object

yr=d.getYear();if(yr<1000)

yr+=1900;return yr;}document.write("<table width=486>");//don't delete this line

 

/* 每一段代表一种风格,不需要的删除即可*/

 

document.write("<TR><TD VALIGN=TOP><P>风格一<P></TD><TD VALIGN=TOP>"+isnDays[today.getDay()]

+","+isnMonths[today.getMonth()]+""+today.getDate()+","

+getFullYear(today)+"<P>");document.write("<TR><TD VALIGN=TOP>风格二<P></TD><TD VALIGN=TOP>"+clckh+":"+clckm

+":"+clcks+""+clck+"<P></TD></TR>");document.write("<TR><TD VALIGN=TOP>风格三<P></TD><TD VALIGN=TOP>"

+isnDays[today.getDay()]+","+isnMonths[today.getMonth()]+""

+today.getDate()+","+getFullYear(today)+" "+clckh+":"+clckm+":"

+clcks+""+clck+"<P></TD></TR>");document.write("<TR><TD VALIGN=TOP>风格四<P></TD><TD VALIGN=TOP>"

+(today.getMonth()+1)+"/"+today.getDate()+"/"

+(getFullYear(today)+"").substring(2,4)+"<P></TD></TR>");document.write("<TR><TD VALIGN=TOP>风格五:<P></TD><TD VALIGN=TOP>"+hrs+":"+clckm+":"+clcks+"<P></TD></TR>");document.write("<TR><TD VALIGN=TOP>风格六:<P></TD><TD>"+today+"<P></TD></TR>");document.write("<TR><TD VALIGN=TOP>风格七<P></TD><TD>"+navigator.appName+"<P></TD></TR>");document.write("<TR><TD VALIGN=TOP>风格八:<P></TD><TD VALIGN=TOP>"+navigator.appVersion+"<P></TD></TR>");document.write("</table>"); // don't delete this line

//-->

 

</SCRIPT>

 

0 Comments

Wed

18

Mar

2009

44、不错的挂历日期

44、不错的挂历日期

<html>

<head>

<title>网页特效---Cool日历</title>

</head><BODY background="../images/bg.gif">

<!--将以下代码加入HTML<Body></Body>之间-->

<script language="JavaScript">

<!-- Hide this script from old browsers --

function greeting()

{

var today = new Date();

var hrs = today.getHours();

document.writeln("<CENTER>");

document.write("Good ");

if (hrs < 6)

document.write("(Early) Morning");

else if (hrs < 12)

document.write("Morning");

else if (hrs <= 18)

document.write("Afternoon");

else

document.write("Evening");

document.write("!");

 

document.write("当前时间是:");

dayStr = today.toLocaleString();

document.write(dayStr);

document.writeln("</CENTER>");

}

function montharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11)

{

this[0] = m0;

this[1] = m1;

this[2] = m2;

this[3] = m3;

this[4] = m4;

this[5] = m5;

this[6] = m6;

this[7] = m7;

this[8] = m8;

this[9] = m9;

this[10] = m10;

this[11] = m11;

}

function calendar()

{

 

var today = new Date();

var thisDay;

var monthDays = new montharr(31, 28, 31, 30, 31, 30, 31, 31, 30,

31, 30, 31);

 

year = today.getYear();

if (year<2000)

year=year+1900;

 

thisDay = today.getDate();

 

if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))

monthDays[1] = 29;

nDays = monthDays[today.getMonth()];

firstDay = today;

firstDay.setDate(1); // works fine for most systems

testMe = firstDay.getDate();

if (testMe == 2)

firstDay.setDate(0);

startDay = firstDay.getDay();

 

document.writeln("<CENTER>");

document.write("<TABLE BORDER bgcolor=moccasin>");

document.write("<TR><TH COLSPAN=7>");

document.write(year+'');

document.write(today.getMonth()+1+'');

 

 

document.write("<TR><TH><TH><TH><TH><TH><TH><TH>");

document.write("<TR>");

column = 0;

for (i=0; i<startDay; i++)

{

document.write("<TD>");

column++;

}

for (i=1; i<=nDays; i++)

{

document.write("<TD>");

if (i == thisDay)

document.write("<FONT COLOR=\"red\">")

document.write(i);

if (i == thisDay)

document.write("</FONT>")

column++;

if (column == 7)

{

document.write("<TR>");

column = 0;

}

}

document.write("</TABLE>");

document.writeln("</CENTER>");

}

greeting();

document.write("<br>");

calendar();

document.write("");

// -- End Hiding Here -->

</script>

</body></html>

 

0 Comments

Wed

18

Mar

2009

43、又一个挂历的时间代码

43、又一个挂历的时间代码

<html>

 

<head>

<title>网页特效---爪哇日历</title>

<meta content="text/html; charset=gb2312" http-equiv="Content-Type">

 

<script language="JavaScript">

<!--

setCal()

function getTime() {

       var now = new Date()

       var hour = now.getHours()

       var minute = now.getMinutes()

       now = null

       var ampm = ""

       if (hour >= 12) {

              hour -= 12

              ampm = "下午"

       } else

              ampm = "上午"

       hour = (hour == 0) ? 12 : hour

       if (minute < 10)

              minute = "0" + minute

       return hour + ":" + minute + " " + ampm

}

function leapYear(year) {

       if (year % 4 == 0)

              return true

              return false

}

 

function getDays(month, year) {

       var ar = new Array(12)

       ar[0] = 31

       ar[1] = (leapYear(year)) ? 29 : 28

       ar[2] = 31

       ar[3] = 30

       ar[4] = 31

       ar[5] = 30

       ar[6] = 31

       ar[7] = 31

       ar[8] = 30

       ar[9] = 31

       ar[10] = 30

       ar[11] = 31

       return ar[month]

}

 

function getMonthName(month) {

       var ar = new Array(12)

       ar[0] = "1"

       ar[1] = "2"

       ar[2] = "3"

       ar[3] = "4"

       ar[4] = "5"

       ar[5] = "6"

       ar[6] = "7"

       ar[7] = "8"

       ar[8] = "9"

       ar[9] = "10"

       ar[10] = "11"

       ar[11] = "12"

       return ar[month]

}

function setCal() {

       var now = new Date()

       var year = now.getYear()

if (year<2000)

year=1900+year;

       var month = now.getMonth()

       var monthName = getMonthName(month)

       var date = now.getDate()

       now = null

       var firstDayInstance = new Date(year, month, 1)

       var firstDay = firstDayInstance.getDay()

       firstDayInstance = null

       var days = getDays(month, year)

       drawCal(firstDay + 1, days, date, monthName, year)

}

function drawCal(firstDay, lastDate, date, monthName, year) {

       var headerHeight = 50

       var border = 2

       var cellspacing = 4

       var headerColor = "midnightblue"

       var headerSize = "-1"

       var colWidth = 50

       var dayCellHeight = 10

       var dayColor = "darkblue"

       var cellHeight = 20

       var todayColor = "red"

       var timeColor = "purple"

       var text = ""

       text += '<CENTER>'

       text += '<TABLE BORDER=1'  + ' CELLSPACING=0'  + 'style="font-size: 9pt">'

       text +=   '<TH COLSPAN=7 HEIGHT=' + headerHeight + '>'

       text +=          ''

       text +=                 year+''+ monthName + '日历' 

       text +=          ''

       text +=   '</TH>'

       var openCol = '<TD WIDTH=' + colWidth + ' HEIGHT=' + dayCellHeight + '>'

       openCol += '<FONT COLOR="' + dayColor + '">'

       var closeCol = '</FONT></TD>'

       var weekDay = new Array(7)

       weekDay[0] = "星期天"

       weekDay[1] = "星期一"

       weekDay[2] = "星期二"

       weekDay[3] = "星期三"

       weekDay[4] = "星期四"

       weekDay[5] = "星期五"

       weekDay[6] = "星期六"

       text += '<TR ALIGN="center" VALIGN="center"  style="font-size: 9pt">'

       for (var dayNum = 0; dayNum < 7; ++dayNum) {

              text += openCol + weekDay[dayNum] + closeCol

       }

       text += '</TR>'

       var digit = 1

       var curCell = 1

       for (var row = 1; row <= Math.ceil((lastDate + firstDay - 1) / 7); ++row) {

              text += '<TR ALIGN="right" VALIGN="top" style="font-size: 9pt">'

              for (var col = 1; col <= 7; ++col) {

                     if (digit > lastDate)

                            break

                     if (curCell < firstDay) {

                            text += '<TD></TD>';

                            curCell++

                     } else {

                            if (digit == date) {

                                   text += '<TD HEIGHT=1>'

                                   text += '<FONT COLOR="' + todayColor + '">'

                                   text += digit

                                   text += '</FONT><BR>'

                                   text += '<FONT COLOR="' + timeColor + '" SIZE=2 style="font-size: 9pt">'

                                   text += '<CENTER>' + getTime() + '</CENTER>'

                                   text += '</FONT>'

                                   text += '</TD>'

                            } else

                                   text += '<TD HEIGHT=' + cellHeight + '>' + digit + '</TD>'

                            digit++

                     }

              }

              text += '</TR>'

       }

       text += '</TABLE>'

       text += '</CENTER>'

       document.write(text)

}

//-->

</script>

<script language="JavaScript">

<!--

function MM_reloadPage(init) {  //reloads the window if Nav4 resized

  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {

    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}

  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

}

MM_reloadPage(true);

// -->

</script>

</head>

 

<body>

 

</body>

</html>

 

0 Comments

Wed

18

Mar

2009

42、不错的时钟代码

42、不错的时钟代码

<html>

 

<head>

<title>网页特效---JavaScript时钟</title>

<style type="text/css">BODY {

       FONT-FAMILY: "宋体"; FONT-SIZE: 9pt; MARGIN-LEFT: 4px; MARGIN-RIGHT: 0px; MARGIN-TOP: 0px

}

A {

       COLOR: black; FONT-SIZE: 13px; FONT-WEIGHT: 400; TEXT-DECORATION: none

}

A:hover {

       COLOR: red; FONT-SIZE: 13px; FONT-WEIGHT: 400; TEXT-DECORATION: underline

}

A:active {

       COLOR: #ff0033; CURSOR: hand; FONT: 9pt "宋体"

}

</style>

<meta content="text/html; charset=gb2312" http-equiv="Content-Type">

<script language="javascript">

<!--

pX=140;pY=160

obs = new Array(13)

function ob () {

for (i=0; i<13; i++) {

       if (document.all) obs[i]=new Array (eval('ob'+i).style,-100,-100)

       else obs[i] = new Array (eval('document.ob'+i),-100,-100)

       }

}

function cl(a,b,c){

       if (document.all) {

              if (a!=0) b+=-1

              eval('c'+a+'.style.pixelTop='+(pY+(c)))

              eval('c'+a+'.style.pixelLeft='+(pX+(b)))

              }

else{

       if (a!=0) b+=10

       eval('document.c'+a+'.top='+(pY+(c)))

       eval('document.c'+a+'.left='+(pX+(b)))

}

if (document.all) c0.style.pixelLeft=26

}

 

function runClock() {

       for (i=0; i<13; i++) {

              obs[i][0].left=obs[i][1]+pX

              obs[i][0].top=obs[i][2]+pY

       }

}

 

var lastsec

function timer() {

       time = new Date ()

       sec = time.getSeconds()

       if (sec!=lastsec) {

 

              lastsec = sec

              sec=Math.PI*sec/30

              min=Math.PI*time.getMinutes()/30

              hr =Math.PI*((time.getHours()*60)+time.getMinutes())/360

              for (i=1;i<6;i++) {

                     obs[i][1] = Math.sin(sec) * (44 - (i-1)*11)-16;

                     if (document.layers)obs[i][1]+=10;

                     obs[i][2] = -Math.cos(sec) * (44 - (i-1)*11)-27;

              }

              for (i=6;i<10;i++) {

                     obs[i][1] = Math.sin(min) * (40 - (i-6)*10)-16;

                     if (document.layers)obs[i][1]+=10;

                     obs[i][2] = -Math.cos(min) * (40 - (i-6)*10)-27;

              }

              for (i=10;i<13;i++) {

                     obs[i][1] = Math.sin(hr) * (37 - (i-10)*11)-16;

                     if (document.layers)obs[i][1]+=10;

                     obs[i][2] = -Math.cos(hr) * (37 - (i-10)*11)-27;

              }

       }

 

}

function setNum(){

 

cl (0,-67,-65);

cl (1,10,-51);

cl (2,28,-33);

cl (3,35,-8);

cl (4,28,17);

cl (5,10,35);

cl (6,-15,42);

cl (7,-40,35);

cl (8,-58,17);

cl (9,-65,-8);

cl (10,-58,-33);

cl (11,-40,-51);

cl (12,-16,-56);

 

}

 

//-->

 

 

</script>

 

</head>

 

<body

onload="ob(),setNum(),setInterval('timer()',100);setInterval('runClock()',100)">

<div id="c0" style="position: absolute; right: 6px; top: 6; z-index: 2; left: 4; width: 536; height: 19"></div><div

id="c1" style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><b>

 

<p>1</b></p>

</div><div id="c2"

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><b>

 

<p>2</b></p>

</div><div id="c3"

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><b>

 

<p>3</b></p>

</div><div id="c4"

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><b>

 

<p>4</b></p>

</div><div id="c5"

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><b>

 

<p>5</b></p>

</div><div id="c6"

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><b>

 

<p>6</b></p>

</div><div id="c7"

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><b>

 

<p>7</b></p>

</div><div id="c8"

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><b>

 

<p>8</b></p>

</div><div id="c9"

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><b>

 

<p>9</b></p>

</div><div id="c10"

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><b>

 

<p>10</b></p>

</div><div id="c11"

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><b>

 

<p>11</b></p>

</div><div id="c12"

style="FONT-SIZE: 11px; LEFT: 20px; POSITION: absolute; TOP: -20px; Z-INDEX: 5"><b>

 

<p>12</b></p>

</div><div id="ob0" style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 1"></div><div

id="ob1" style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><font

color="#0000ff" size="+3"><b>

 

<p>.</b></font></p>

</div><div id="ob2" style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><font

color="#0000ff" size="+3"><b>

 

<p>.</b></font></p>

</div><div id="ob3" style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><font

color="#0000ff" size="+3"><b>

 

<p>.</b></font></p>

</div><div id="ob4" style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><font

color="#0000ff" size="+3"><b>

 

<p>.</b></font></p>

</div><div id="ob5" style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 8"><font

color="#0000ff" size="+3"><b>

 

<p>.</b></font></p>

</div><div id="ob6" style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><font

color="#00ffff" size="+3"><b>

 

<p>.</b></font></p>

</div><div id="ob7" style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><font

color="#00ffff" size="+3"><b>

 

<p>.</b></font></p>

</div><div id="ob8" style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><font

color="#00ffff" size="+3"><b>

 

<p>.</b></font></p>

</div><div id="ob9" style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 7"><font

color="#00ffff" size="+3"><b>

 

<p>.</b></font></p>

</div><div id="ob10" style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 6"><font

color="#f30000" size="+3"><b>

 

<p>.</b></font></p>

</div><div id="ob11" style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 6"><font

color="#f30000" size="+3"><b>

 

<p>.</b></font></p>

</div><div id="ob12" style="LEFT: -20px; POSITION: absolute; TOP: -20px; Z-INDEX: 6"><font

color="#f30000" size="+3"><b>

 

<p>.</b></font></p>

</div>

 

</body>

</html>

 

0 Comments

Wed

18

Mar

2009

41、一个挂历的时间代码

41、一个挂历的时间代码

<html>

 

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>网页特效---挂历的时间显示</title>

</head>

 

<body>

 

<SCRIPT language=JavaScript>

function Year_Month(){

var now = new Date();

var yy = now.getYear();

var mm = now.getMonth()+1;

var cl = '<font color="#0000df">';

if (now.getDay() == 0) cl = '<font color="#c00000">';

if (now.getDay() == 6) cl = '<font color="#00c000">';

return(cl + yy + '' + mm + '</font>'); }

function Date_of_Today(){

var now = new Date();

var cl = '<font color="#ff0000">';

if (now.getDay() == 0) cl = '<font color="#c00000">';

if (now.getDay() == 6) cl = '<font color="#00c000">';

return(cl + now.getDate() + '</font>'); }

function Day_of_Today(){

var day = new Array();

day[0] = "星期日";

day[1] = "星期一";

day[2] = "星期二";

day[3] = "星期三";

day[4] = "星期四";

day[5] = "星期五";

day[6] = "星期六";

var now = new Date();

var cl = '<font color="#0000df">';

if (now.getDay() == 0) cl = '<font color="#c00000">';

if (now.getDay() == 6) cl = '<font color="#00c000">';

return(cl + day[now.getDay()] + '</font>'); }

function CurentTime(){

var now = new Date();

var hh = now.getHours();

var mm = now.getMinutes();

var ss = now.getTime() % 60000;

ss = (ss - (ss % 1000)) / 1000;

var clock = hh+':';

if (mm < 10) clock += '0';

clock += mm+':';

if (ss < 10) clock += '0';

clock += ss;

return(clock); }

function refreshCalendarClock(){

document.all.calendarClock1.innerHTML = Year_Month();

document.all.calendarClock2.innerHTML = Date_of_Today();

document.all.calendarClock3.innerHTML = Day_of_Today();

document.all.calendarClock4.innerHTML = CurentTime(); }

var webUrl = webUrl;

document.write('<table border="0" cellpadding="0" cellspacing="0"><tr><td>');

document.write('<table id="CalendarClockFreeCode" border="0" cellpadding="0" cellspacing="0" width="60" height="70" ');

document.write('style="position:absolute;visibility:hidden" bgcolor="#eeeeee">');

document.write('<tr><td align="center"><font ');

document.write('style="cursor:hand;color:#ff0000;font-family:宋体;font-size:14pt;line-height:120%" ');

if (webUrl != 'netflower'){

document.write('</td></tr><tr><td align="center"><font ');

document.write('style="cursor:hand;color:#2000ff;font-family:宋体;font-size:9pt;line-height:110%" ');

}

document.write('</td></tr></table>');

document.write('<table border="0" cellpadding="0" cellspacing="0" width="61" bgcolor="#C0C0C0" height="70">');

document.write('<tr><td valign="top" width="100%" height="100%">');

document.write('<table border="1" cellpadding="0" cellspacing="0" width="58" bgcolor="#FEFEEF" height="67">');

document.write('<tr><td align="center" width="100%" height="100%" >');

document.write('<font id="calendarClock1" style="font-family:宋体;font-size:7pt;line-height:120%"> </font><br>');

document.write('<font id="calendarClock2" style="color:#ff0000;font-family:Arial;font-size:14pt;line-height:120%"> </font><br>');

document.write('<font id="calendarClock3" style="font-family:宋体;font-size:9pt;line-height:120%"> </font><br>');

document.write('<font id="calendarClock4" style="color:#100080;font-family:宋体;font-size:8pt;line-height:120%"><b> </b></font>');

document.write('</td></tr></table>');

document.write('</td></tr></table>');

document.write('</td></tr></table>');

setInterval('refreshCalendarClock()',1000);

</SCRIPT>

 

</body>

 

</html>

 

0 Comments

Wed

18

Mar

2009

40、不错的万年历查询

40、不错的万年历查询

<HTML><HEAD><TITLE>网页特效--又一款很不错的万年历查询</TITLE>

<META http-equiv=Content-Type content="text/html; charset=gb2312">

<STYLE type=text/css>BODY {

       FONT-SIZE: 14px; SCROLLBAR-HIGHLIGHT-COLOR: buttonface; SCROLLBAR-SHADOW-COLOR: buttonface; COLOR: #333333; SCROLLBAR-3DLIGHT-COLOR: buttonhighlight; SCROLLBAR-TRACK-COLOR: #eeeeee; FONT-FAMILY: "Times New Roman", "宋体"; SCROLLBAR-DARKSHADOW-COLOR: buttonshadow

}

TD {

       FONT-SIZE: 14px; COLOR: #333333

}

.input1 {

       BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 1px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 1px; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; BORDER-LEFT: #cccccc 1px solid; CURSOR: text; COLOR: #333333; PADDING-TOP: 1px; BORDER-BOTTOM: #cccccc 1px solid; FONT-FAMILY: "Times New Roman", "宋体"; HEIGHT: 24px

}

</STYLE>

 

<SCRIPT language=JavaScript>

<!--

function click()

{

if (event.button==2)

{

//     return (0);

alert('欢迎使用万年历系统!') ;

}

}

document.onmousedown=click

//-->

</SCRIPT>

 

<SCRIPT language=JavaScript>

<!--

var lunarInfo=new Array(

0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2,

0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x14977,

0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970,

0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,

0x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x0b557,

0x06ca0,0x0b550,0x15355,0x04da0,0x0a5d0,0x14573,0x052d0,0x0a9a8,0x0e950,0x06aa0,

0x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,

0x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b5a0,0x195a6,

0x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x09570,

0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x092e0,

0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5,

0x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x0a930,

0x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530,

0x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x0dd45,

0x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x0ada0)

var solarMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);

var Gan=new Array("","","","","","","","","","");

var Zhi=new Array("","","","","","","","","","","","");

var Animals=new Array("","","","","","","","","","","","");

var solarTerm = new Array("小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至")

var sTermInfo = new Array(0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,240693,263343,285989,308563,331033,353350,375494,397447,419210,440795,462224,483532,504758)

var nStr1 = new Array('','','','','','','','','','','')

var nStr2 = new Array('','','廿','',' ')

//var monthName = new Array("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC");

var monthName = new Array("1","2","3","4","5","6","7","8","9","10","11","12");

 

var sFtv = new Array(

"0101*元旦",

"0214 情人节",

"0308 妇女节",

"0312 植树节",

"0315 消费者权益日",

"0401 愚人节",

"0501 劳动节",

"0504 青年节",

"0512 护士节",

"0601 儿童节",

"0701 建党节 香港回归纪念",

"0703 炎黄在线诞辰",

"0718 托普诞辰",

"0801 建军节",

"0808 父亲节",

"0909 毛泽东逝世纪念",

"0910 教师节",

"0928 孔子诞辰",

"1001*国庆节",

"1006 老人节",

"1024 联合国日",

"1112 孙中山诞辰纪念",

"1220 澳门回归纪念",

"1225 Christmas Day",

"1226 毛泽东诞辰纪念")

 

var lFtv = new Array(

"0101*春节",

"0115 元宵节",

"0505 端午节",

"0707 七夕情人节",

"0715 中元节",

"0815 中秋节",

"0909 重阳节",

"1208 腊八节",

"1224 小年",

"0100*除夕")

 

var wFtv = new Array(

"0131 Martin Luther King Day",

"0231 President's Day",

"0520 母亲节",

"0530 Armed Forces Day",

"0531 Victoria Day",

"0716 合作节",

"0730 被奴役国家周",

"0811 Civic Holiday",

"0911 Labor Holiday",

"1021 Columbus Day",

"1144 Thanksgiving Day")

 

function lYearDays(y) {

   var i, sum = 348

   for(i=0x8000; i>0x8; i>>=1) sum += (lunarInfo[y-1900] & i)? 1: 0

   return(sum+leapDays(y))

}

 

function leapDays(y) {

   if(leapMonth(y))  return((lunarInfo[y-1900] & 0x10000)? 30: 29)

   else return(0)

}

 

function leapMonth(y) {

   return(lunarInfo[y-1900] & 0xf)

}

 

function monthDays(y,m) {

   return( (lunarInfo[y-1900] & (0x10000>>m))? 30: 29 )

}

 

function Lunar(objDate) {

 

   var i, leap=0, temp=0

   var baseDate = new Date(1900,0,31)

   var offset   = (objDate - baseDate)/86400000

 

   this.dayCyl = offset + 40

   this.monCyl = 14

 

   for(i=1900; i<2050 && offset>0; i++) {

      temp = lYearDays(i)

      offset -= temp

      this.monCyl += 12

   }

 

   if(offset<0) {

      offset += temp;

      i--;

      this.monCyl -= 12

   }

 

   this.year = i

   this.yearCyl = i-1864

 

   leap = leapMonth(i)

   this.isLeap = false

 

   for(i=1; i<13 && offset>0; i++) {

     

      if(leap>0 && i==(leap+1) && this.isLeap==false)

         { --i; this.isLeap = true; temp = leapDays(this.year); }

      else

         { temp = monthDays(this.year, i); }

 

    

      if(this.isLeap==true && i==(leap+1)) this.isLeap = false

 

      offset -= temp

      if(this.isLeap == false) this.monCyl ++

   }

 

   if(offset==0 && leap>0 && i==leap+1)

      if(this.isLeap)

         { this.isLeap = false; }

      else

         { this.isLeap = true; --i; --this.monCyl;}

 

   if(offset<0){ offset += temp; --i; --this.monCyl; }

 

   this.month = i

   this.day = offset + 1

}

 

function solarDays(y,m) {

   if(m==1)

      return(((y%4 == 0) && (y%100 != 0) || (y%400 == 0))? 29: 28)

   else

      return(solarMonth[m])

}

function cyclical(num) {

   return(Gan[num%10]+Zhi[num%12])

}

 

function calElement(sYear,sMonth,sDay,week,lYear,lMonth,lDay,isLeap,cYear,cMonth,cDay) {

 

      this.isToday    = false;

      this.sYear      = sYear;

      this.sMonth     = sMonth;

      this.sDay       = sDay;

      this.week       = week;

      this.lYear      = lYear;

      this.lMonth     = lMonth;

      this.lDay       = lDay;

      this.isLeap     = isLeap;

      this.cYear      = cYear;

      this.cMonth     = cMonth;

      this.cDay       = cDay;

 

      this.color      = '';

 

      this.lunarFestival = ''; //农历节日

      this.solarFestival = ''; //国历节日

      this.solarTerms    = ''; //节气

 

}

 

function sTerm(y,n) {

   var offDate = new Date( ( 31556925974.7*(y-1900) + sTermInfo[n]*60000  ) + Date.UTC(1900,0,6,2,5) )

   return(offDate.getUTCDate())

}

 

function calendar(y,m) {

 

   var sDObj, lDObj, lY, lM, lD=1, lL, lX=0, tmp1, tmp2

   var lDPOS = new Array(3)

   var n = 0

   var firstLM = 0

 

   sDObj = new Date(y,m,1)            //当月一日日期

 

   this.length    = solarDays(y,m)    //国历当月天数

   this.firstWeek = sDObj.getDay()    //国历当月1日星期几

 

 

   for(var i=0;i<this.length;i++) {

 

      if(lD>lX) {

         sDObj = new Date(y,m,i+1)    //当月一日日期

         lDObj = new Lunar(sDObj)     //农历

         lY    = lDObj.year           //农历年

         lM    = lDObj.month          //农历月

         lD    = lDObj.day            //农历日

         lL    = lDObj.isLeap         //农历是否闰月

         lX    = lL? leapDays(lY): monthDays(lY,lM) //农历当月最後一天

 

         if(n==0) firstLM = lM

         lDPOS[n++] = i-lD+1

      }

 

      //sYear,sMonth,sDay,week,

      //lYear,lMonth,lDay,isLeap,

      //cYear,cMonth,cDay

      this[i] = new calElement(y, m+1, i+1, nStr1[(i+this.firstWeek)%7],

                               lY, lM, lD++, lL,

                               cyclical(lDObj.yearCyl) ,cyclical(lDObj.monCyl), cyclical(lDObj.dayCyl++) )

 

 

      if((i+this.firstWeek)%7==0)   this[i].color = 'red'  //周日颜色

      if((i+this.firstWeek)%14==13) this[i].color = 'red'  //周休二日颜色

   }

 

   tmp1=sTerm(y,m*2  )-1

   tmp2=sTerm(y,m*2+1)-1

   this[tmp1].solarTerms = solarTerm[m*2]

   this[tmp2].solarTerms = solarTerm[m*2+1]

   if(m==3) this[tmp1].color = 'red' //清明颜色

 

   for(i in sFtv)

      if(sFtv[i].match(/^(\d{2})(\d{2})([\s\*])(.+)$/))

         if(Number(RegExp.$1)==(m+1)) {

            this[Number(RegExp.$2)-1].solarFestival += RegExp.$4 + ' '

            if(RegExp.$3=='*') this[Number(RegExp.$2)-1].color = 'red'

         }

 

   for(i in wFtv)

      if(wFtv[i].match(/^(\d{2})(\d)(\d)([\s\*])(.+)$/))

         if(Number(RegExp.$1)==(m+1)) {

            tmp1=Number(RegExp.$2)

            tmp2=Number(RegExp.$3)

            this[((this.firstWeek>tmp2)?7:0) + 7*(tmp1-1) + tmp2 - this.firstWeek].solarFestival += RegExp.$5 + ' '

         }

 

   //农历节日

   for(i in lFtv)

      if(lFtv[i].match(/^(\d{2})(.{2})([\s\*])(.+)$/)) {

         tmp1=Number(RegExp.$1)-firstLM

         if(tmp1==-11) tmp1=1

         if(tmp1 >=0 && tmp1<n) {

            tmp2 = lDPOS[tmp1] + Number(RegExp.$2) -1

            if( tmp2 >= 0 && tmp2<this.length) {

               this[tmp2].lunarFestival += RegExp.$4 + ' '

               if(RegExp.$3=='*') this[tmp2].color = 'red'

            }

         }

      }

 

   //黑色星期五

   if((this.firstWeek+12)%7==5)

      this[12].solarFestival += '黑色星期五 '

 

   //今日

   if(y==tY && m==tM) this[tD-1].isToday = true;

 

}

 

//====================== 中文日期

function cDay(d){

   var s;

 

   switch (d) {

      case 10:

         s = '初十'; break;

      case 20:

         s = '二十'; break;

         break;

      case 30:

         s = '三十'; break;

         break;

      default :

         s = nStr2[Math.floor(d/10)];

         s += nStr1[d%10];

   }

   return(s);

}

 

///////////////////////////////////////////////////////////////////////////////

 

var cld;

 

function drawCld(SY,SM) {

   var i,sD,s,size;

   cld = new calendar(SY,SM);

 

   if(SY>1874 && SY<1909) yDisplay = '光绪' + (((SY-1874)==1)?'':SY-1874)

   if(SY>1908 && SY<1912) yDisplay = '宣统' + (((SY-1908)==1)?'':SY-1908)

   if(SY>1911 && SY<1950) yDisplay = '民国' + (((SY-1911)==1)?'':SY-1911)

//   if(SY>1949) yDisplay = '共和国' + (((SY-1949)==1)?'':SY-1949)

 

  // GZ.innerHTML = yDisplay +' 农历' + cyclical(SY-1900+36) + '年('+Animals[(SY-4)%12]+'';

 

   if(SY>1949) yDisplay = ''

 

   GZ.innerHTML = yDisplay +' 农历' + cyclical(SY-1900+36) + '年('+Animals[(SY-4)%12]+'';

 

   YMBG.innerHTML = SY + "" + monthName[SM] + "";

 

 

   for(i=0;i<42;i++) {

 

      sObj=eval('SD'+ i);

      lObj=eval('LD'+ i);

 

      sObj.className = '';

 

      sD = i - cld.firstWeek;

 

      if(sD>-1 && sD<cld.length) {

         sObj.innerHTML = sD+1;

 

         if(cld[sD].isToday) sObj.className = 'todyaColor';

 

         sObj.style.color = cld[sD].color;

 

         if(cld[sD].lDay==1)

            lObj.innerHTML = '<b>'+(cld[sD].isLeap?'':'') + cld[sD].lMonth + '' + (monthDays(cld[sD].lYear,cld[sD].lMonth)==29?'':'')+'</b>';

         else

            lObj.innerHTML = cDay(cld[sD].lDay);

 

         s=cld[sD].lunarFestival;

         if(s.length>0) {

            if(s.length>6) s = s.substr(0, 4)+'…';

            s = s.fontcolor('red');

         }

         else { //国历节日

            s=cld[sD].solarFestival;

            if(s.length>0) {

               size = (s.charCodeAt(0)>0 && s.charCodeAt(0)<128)?8:4;

               if(s.length>size+2) s = s.substr(0, size)+'…';

               s = s.fontcolor('blue');

            }

            else { //廿四节气

               s=cld[sD].solarTerms;

               if(s.length>0) s = s.fontcolor('limegreen');

            }

         }

         if(s.length>0) lObj.innerHTML = s;

 

      }

      else { //非日期

         sObj.innerHTML = '';

         lObj.innerHTML = '';

      }

   }

}

 

function changeLong()

{

var y,m,ly,lm,id,im,iy,yangy,yangm,deltm,miny,tt;

CLD.SY.selectedIndex=CLD.D1.selectedIndex;

CLD.SM.selectedIndex=CLD.D2.selectedIndex;

yangm=0;yangy=0;

tt=true;

while (tt)

       {

       yangm=0;yangy=0;

                     changeCld();

                 for(i=0;i<42;i++)

                 {

                    sD = i - cld.firstWeek;

                    if(sD>-1 && sD<cld.length)

                    { //日期内

                           if ((cld[sD].lMonth==CLD.D2.selectedIndex+1)&&(cld[sD].lYear==CLD.D1.selectedIndex+1900))

                           {

                                   yangy=CLD.SY.selectedIndex+1900;   yangm=CLD.SM.selectedIndex ;

                                   tt=false;

                                   break;

                                   }

                        }

                 }

                 if (!tt) break;

                

                     pushBtm('MD');

                     changeCld();

 

//                   alert(CLD.SY.selectedIndex+" "+CLD.SM.selectedIndex);

 

                 for(i=0;i<42;i++)

                 {

                    sD = i - cld.firstWeek;

                    if(sD>-1 && sD<cld.length)

                    { //日期内

                           if ((cld[sD].lMonth==CLD.D2.selectedIndex+1)&&(cld[sD].lYear==CLD.D1.selectedIndex+1900))

                           {

                                   yangy=CLD.SY.selectedIndex+1900;   yangm=CLD.SM.selectedIndex ;

                                   tt=false;

                                   break;

                                   }

                        }

                 }

                     break;              

       }

//            alert(yangy+" "+yangm);

      

//CLD.SY.selectedIndex=yangy;//-1900;

//pushBtm('YU');

//pushBtm('YD');

CLD.SM.selectedIndex=yangm;

pushBtm('MD');

pushBtm('MU');

 

}

//changeLong end

 

function changeCld() {

   var y,m;

   y=CLD.SY.selectedIndex+1900;

   m=CLD.SM.selectedIndex;

   drawCld(y,m);

}

 

function pushBtm(K) {

   switch (K){

      case 'YU' :

         if(CLD.SY.selectedIndex>0) CLD.SY.selectedIndex--;

         break;

      case 'YD' :

         if(CLD.SY.selectedIndex<149) CLD.SY.selectedIndex++;

         break;

      case 'MU' :

         if(CLD.SM.selectedIndex>0) {

            CLD.SM.selectedIndex--;

         }

         else {

            CLD.SM.selectedIndex=11;

            if(CLD.SY.selectedIndex>0) CLD.SY.selectedIndex--;

         }

         break;

      case 'MD' :

         if(CLD.SM.selectedIndex<11) {

            CLD.SM.selectedIndex++;

         }

         else {

            CLD.SM.selectedIndex=0;

            if(CLD.SY.selectedIndex<149) CLD.SY.selectedIndex++;

         }

         break;

      default :

         CLD.SY.selectedIndex=tY-1900;

         CLD.SM.selectedIndex=tM;

   }

   changeCld();

}

 

var Today = new Date();

var tY = Today.getFullYear();

var tM = Today.getMonth();

var tD = Today.getDate();

//////////////////////////////////////////////////////////////////////////////

 

var width = "130";

var offsetx = 2;

var offsety = 16;

 

var x = 0;

var y = 0;

var snow = 0;

var sw = 0;

var cnt = 0;

 

var dStyle;

document.onmousemove = mEvn;

 

//显示详细日期资料

function mOvr(v) {

   var s,festival;

   var sObj=eval('SD'+ v);

   var d=sObj.innerHTML-1;

 

      //sYear,sMonth,sDay,week,

      //lYear,lMonth,lDay,isLeap,

      //cYear,cMonth,cDay

 

   if(sObj.innerHTML!='') {

 

      sObj.style.cursor = 's-resize';

 

      if(cld[d].solarTerms == '' && cld[d].solarFestival == '' && cld[d].lunarFestival == '')

         festival = '';

      else

         festival = '<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=0 BGCOLOR="#333333"><TR><TD ALIGN="RIGHT">'+

         '<FONT style="color:#FFFFFF; font-size:9pt">'+cld[d].solarTerms + ' ' + cld[d].solarFestival + ' ' + cld[d].lunarFestival+'</FONT></TD>'+

         '</TR></TABLE>';

 

      s= '<TABLE WIDTH="140" BORDER=0 CELLPADDING="0" CELLSPACING=0 BGCOLOR="#000099"><TR><TD>' +

         '<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=0><TR><TD ALIGN="RIGHT" nowrap><FONT style="color:#FFFFFF; font-size:9pt">'+

         cld[d].sYear+' '+cld[d].sMonth+' '+cld[d].sDay+'<br>星期'+cld[d].week+'<br>'+

         '<font color="fuchsia">农历'+(cld[d].isLeap?' ':' ')+cld[d].lMonth+' '+cld[d].lDay+'</font><br>'+

         '<font color="yellow">'+cld[d].cYear+' '+cld[d].cMonth+' '+cld[d].cDay + '</font>'+

         '</FONT></TD></TR></TABLE>'+ festival +'</TD></TR></TABLE>';

 

 

      document.all["detail"].innerHTML = s;

 

     if (snow == 0) {

         dStyle.left = x+offsetx-(width/2);

         dStyle.top = y+offsety;

            dStyle.visibility = "visible";

            snow = 1;

     }

       }

}

 

//清除详细日期资料

function mOut() {

       if ( cnt >= 1 ) { sw = 0 }

       if ( sw == 0 )

       { snow = 0;

       dStyle.visibility="hidden";}

       else cnt++;

}

 

//取得位置

function mEvn() {

   x=event.x;

   y=event.y;

       if (document.body.scrollLeft)

          {x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}

       if (snow){

      dStyle.left = x+offsetx-(width/2)

      dStyle.top = y+offsety

       }

}

 

///////////////////////////////////////////////////////////////////////////

 

function tick() {

   var today

   today = new Date()

   Clock.innerHTML = today.toLocaleString().replace(/(|)/g, "/").replace(//, "");

//   Clock.innerHTML = TimeAdd(today.toGMTString(), CLD.TZ.value)

   window.setTimeout("tick()", 1000);

}

 

function setCookie(name, value) {

       var today = new Date()

       var expires = new Date()

       expires.setTime(today.getTime() + 1000*60*60*24*365)

       document.cookie = name + "=" + escape(value)   + "; expires=" + expires.toGMTString()

}

 

function getCookie(Name) {

   var search = Name + "="

   if(document.cookie.length > 0) {

      offset = document.cookie.indexOf(search)

      if(offset != -1) {

         offset += search.length

         end = document.cookie.indexOf(";", offset)

         if(end == -1) end = document.cookie.length

         return unescape(document.cookie.substring(offset, end))

      }

      else return ""

   }

}

 

/////////////////////////////////////////////////////////

 

function initial() {

   dStyle = detail.style;

   CLD.SY.selectedIndex=tY-1900;

   CLD.SM.selectedIndex=tM;

   drawCld(tY,tM);

 

//   CLD.TZ.selectedIndex=getCookie("TZ");

//   changeTZ();

   tick();

}

 

//-->

</SCRIPT>

 

<STYLE>.todyaColor {

       BACKGROUND-COLOR: #99ff00

}

</STYLE>

 

<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>

<BODY oncontextmenu=self.event.returnValue=false bgColor=beige leftMargin=0

topMargin=0 onload=initial()>

<TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%" align=center

border=0>

  <FORM name=CLD>

  <TBODY>

  <TR>

    <TD vAlign=center align=middle>

      <SCRIPT language=JavaScript>

<!--

   if(navigator.appName == "Netscape" || parseInt(navigator.appVersion) < 4)

   document.write("<h1>你的浏览器无法执行此程序。</h1>此程序在IE4以后的版本才能执行!!")

//-->

</SCRIPT>

 

      <DIV id=detail

      style="LEFT: 330px; WIDTH: 140px; POSITION: absolute; TOP: 199px; HEIGHT: 16px"></DIV>

      <TABLE cellSpacing=1 cellPadding=1 align=center bgColor=#000000

        border=0><TBODY>

        <TR bgColor=#ffffff>

          <TD vAlign=top width=220>

            <TABLE height="100%" cellSpacing=0 cellPadding=4 width="100%"

            align=center border=0>

              <TBODY>

              <TR height=28>

                <TD align=middle bgColor=#333333><FONT

                color=white>万年历查询</FONT></TD></TR>

              <TR height=*>

                <TD align=middle><FONT id=tSave

                  style="FONT-SIZE: 18pt; COLOR: red; FONT-FAMILY: Wingdings"></FONT>公历:

                  <SELECT class=input1 onchange=changeCld() name=SY>

                    <SCRIPT language=JavaScript>

<!--

for(i=1900;i<2050;i++) document.write('<option>'+i)  

//-->

</SCRIPT>

                  </SELECT> <SELECT class=input1 onchange=changeCld() name=SM>

 

                    <SCRIPT language=JavaScript>

<!--

for(i=1;i<13;i++) document.write('<option>'+i)  

//-->

</SCRIPT>

                  </SELECT><BR><BR>阴历: <SELECT class=input1

                  onchange=changeLong() name=D1>

                    <SCRIPT language=JavaScript>

<!--

for(i=1900;i<2050;i++) document.write('<option>'+i)  

//-->

</SCRIPT>

                  </SELECT> <SELECT class=input1 onchange=changeLong() name=D2>

 

                    <SCRIPT language=JavaScript>

<!--

for(i=1;i<13;i++) document.write('<option>'+i)  

//-->

</SCRIPT>

                  </SELECT><BR><BR><BR><A onclick="pushBtm('')"

                  href="http://www.windstudio.net/calendar.htm####">返回当前月份</A></TD></TR>

              <TR height=28>

                <TD align=middle width=240 bgColor=#dddddd

                  height=28>当前时间:<FONT

                id=Clock></FONT><!--时区 *表示自动调整为日光节约时间--></TD></TR></TBODY></TABLE></TD>

          <TD align=middle width=420 height=255 rowSpan=3>

            <TABLE height=28 cellSpacing=4 cellPadding=0 width="100%"

            bgColor=#333333 border=0>

              <TBODY>

              <TR>

                <TD width=5><FONT title=上一年

                  style="CURSOR: hand; COLOR: #ffffff" onclick="pushBtm('YU')"

                  face=webdings>9</FONT></TD>

                <TD width=5><FONT title=上一月

                  style="CURSOR: hand; COLOR: #ffffff" onclick="pushBtm('MU')"

                  face=webdings>3</FONT></TD>

                <TD><FONT id=YMBG color=#ffffff></FONT></TD>

                <TD align=right><FONT id=GZ color=#ffffff></FONT></TD>

                <TD align=right width=5><FONT title=下一月

                  style="CURSOR: hand; COLOR: #ffffff" onclick="pushBtm('MD')"

                  face=webdings>4</FONT></TD>

                <TD align=right width=5><FONT title=下一年

                  style="CURSOR: hand; COLOR: #ffffff" onclick="pushBtm('YD')"

                  face=webdings>8</FONT></TD></TR></TBODY></TABLE>

            <TABLE cellSpacing=1 cellPadding=0 width="100%" bgColor=#ffffff

            border=0>

              <TBODY>

              <TR align=middle bgColor=#dddddd>

                <TD width=60 height=24></TD>

                <TD width=60></TD>

                <TD width=60></TD>

                <TD width=60></TD>

                <TD width=60></TD>

                <TD width=60></TD>

                <TD width=60></TD></TR>

              <SCRIPT language=JavaScript>

<!--                                                                                                   

            var gNum                                                                                                   

            for(i=0;i<6;i++) {                                                                                                   

               document.write('<tr align=center>')                                                                                                   

               for(j=0;j<7;j++) {                                                                                                    

                  gNum = i*7+j                                                                                                   

                  document.write('<td id="GD' + gNum +'" onMouseOver="mOvr(' + gNum +')" onMouseOut="mOut()" nowrap><font id="SD' + gNum +'" size=2 face="Arial Black"')                                                                                                   

                  if(j == 0) document.write(' color=red')                                                                                                    

                  if(j == 6)                                                                                                   

                     if(i%2==1) document.write(' color=red')                                                                                                    

                        else document.write(' color=green')                                                                                                   

                  document.write(' TITLE=""> </font><br><font id="LD' + gNum + '" style="font-size:9pt"> </font></td>')                                                                                                   

               }                                                                                                    

               document.write('</tr>')                                                                                                   

            }                                                                                                    

//-->

</SCRIPT>

 

              <TR>

                <TD> </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>

      </TD></TR></FORM></TBODY></TABLE></BODY></HTML>

 

0 Comments

Wed

18

Mar

2009

39、显示当前时间代码

39、显示当前时间代码

<html>

<head>

<title>网页特效---当前时间</title>

</head>

<!--将以下代码加入HTML<Body></Body>之间-->

<script language=JavaScript>

var timerID = null;

var timerRunning = false;

function stopclock (){

if(timerRunning)

clearTimeout(timerID);

timerRunning = false;}

function startclock () {

stopclock();

showtime();}

function showtime () {

var now = new Date();

var hours = now.getHours();

var minutes = now.getMinutes();

var seconds = now.getSeconds()

var timeValue = "" +((hours >= 12) ? "下午 " : "上午 " )

timeValue += ((hours >12) ? hours -12 :hours)

timeValue += ((minutes < 10) ? ":0" : ":") + minutes

timeValue += ((seconds < 10) ? ":0" : ":") + seconds

document.clock.thetime.value = timeValue;

timerID = setTimeout("showtime()",1000);

timerRunning = true;}

</SCRIPT>

<body onload=startclock()>

<form name=clock >

<input name=thetime style="font-size: 9pt;color:#000000;border:0px none; " size=12>

</form>

</body></html>

 

0 Comments

Wed

18

Mar

2009

38、可以查询星期的代码

38、可以查询星期的代码

<html>

<head>

<title>网页特效---星期查询!可设置任意、年、月、日</title>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

</head>

<body>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");

var days = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");

var mtend = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

var opt = new Array("过去时间","将来时间");

function getDateInfo() {

var y = document.form.year.value;

var m = document.form.month.options[document.form.month.options.selectedIndex].value;

var d = document.form.day.options[document.form.day.options.selectedIndex].value;

var hlpr = mtend[m];

if (d < mtend[m] + 1) {

if (m == 1 && y % 4 == 0) { hlpr++; }

var c = new Date(y,m,d);

var dayOfWeek = c.getDay();

document.form.dw.value = days[dayOfWeek];

if(c.getTime() > new Date().getTime()) {

document.form.time.value = opt[1];

}

else {

document.form.time.value = opt[0];

   }

}

else {

alert("这一天"+months[m]+" "+d+", "+y+"是不存在的.\n请重新选择.");

   }

}

function setY() {

var y = new Date().getYear();

if (y < 2000) y += 1900;

document.form.year.value = y;

}

//  End -->

</script>

<form name="form">

<p><input type="text" name="year" size="8" value="2004"> <select name="month" size="1">

<option selected value="0">1</option>

<option value="1">2 </option>

<option value="2">3 </option>

<option value="3">4 </option>

<option value="4">5 </option>

<option value="5">6 </option>

<option value="6">7 </option>

<option value="7">8 </option>

<option value="8">9 </option>

<option value="9">10 </option>

<option value="10">11 </option>

<option value="11">12 </option>

</select><select name="day" size="1">

<option selected value="1">1</option>

<option value="2">2</option>

<option value="3">3</option>

<option value="4">4</option>

<option value="5">5</option>

<option value="6">6</option>

<option value="7">7</option>

<option value="8">8</option>

<option value="9">9</option>

<option value="10">10</option>

<option value="11">11</option>

<option value="12">12</option>

<option value="13">13</option>

<option value="14">14</option>

<option value="15">15</option>

<option value="16">16</option>

<option value="17">17</option>

<option value="18">18</option>

<option value="19">19</option>

<option value="20">20</option>

<option value="21">21</option>

<option value="22">22</option>

<option value="23">23</option>

<option value="24">24</option>

<option value="25">25</option>

<option value="26">26</option>

<option value="27">27</option>

<option value="28">28</option>

<option value="29">29</option>

<option value="30">30</option>

<option value="31">31</option>

</select> <input type="button"

value="看看这天的信息" name="gdi" onClick="getDateInfo()"></p>

<p>这里显示是星期几:<input type="text" name="dw" size="12">时间状态:<input type="text"

name="time" size="10"></p>

</form>

 

</body>

</html>

 

0 Comments

Wed

18

Mar

2009

37、距离某某日子还有X天

37、距离某某日子还有X

要完成此效果把如下代码加入到<body>区域中

 

<script language="JavaScript">

 

<!-- // (c) Henryk Gajewski

 

var urodz= new Date("1/1/2005");

 

var  s="今天离200511";

 

var now = new Date();

 

var ile = urodz.getTime() - now.getTime();

 

var dni = Math.floor(ile / (1000 * 60 * 60 * 24));

 

if (dni > 1)

 

   document.write(""+s+"还有"+dni +"")

 

else if (dni == 1)

 

     document.write("只有2天啦!")

 

else if (dni == 0)

 

     document.write("只有1天啦!")

 

else

 

    document.write("好象已经过了哦!");

 

// -->

 

</script>

 

0 Comments

Wed

18

Mar

2009

36、显示离开某事件时间提醒牌

36、显示离开某事件时间提醒牌

要完成此效果把如下代码加入到<body>区域中

 

<SCRIPT language=javascript><!--

 

BirthDay=new Date("january 01,2007");//改成你的计时日期

 

today=new Date();

 

timeold=(today.getTime()-BirthDay.getTime());

 

sectimeold=timeold/1000

 

secondsold=Math.floor(sectimeold);

 

msPerDay=24*60*60*1000

 

e_daysold=timeold/msPerDay

 

daysold=Math.floor(e_daysold);

 

e_hrsold=(e_daysold-daysold)*24;

 

hrsold=Math.floor(e_hrsold);

 

e_minsold=(e_hrsold-hrsold)*60;

 

minsold=Math.floor((e_hrsold-hrsold)*60);

 

seconds=Math.floor((e_minsold-minsold)*60);

 

//-->

 

</SCRIPT><SCRIPT language=javascript><!--

 

document.write("结婚已经 "+daysold+""+hrsold+"小时"+minsold+""+seconds+"秒了!");

 

//-->

 

</SCRIPT>

 

 

 

 

0 Comments

Wed

18

Mar

2009

35、到时时再弹出窗口

35、到时时再弹出窗口

<html>

<head>

<title>bomb</title>

<script language="JavaScript">

var intLeft = 15;

 

function leavePage() {

if (0 == intLeft)

alert('嘻!!!哈哈!开个玩笑!7stk.com ')

else {

 

intLeft -= 1;

document.all.countdown.innerText = intLeft + " ";

setTimeout("leavePage()", 1000);

}

}

</script>

</head>

<body bgcolor=yellow leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="setTimeout('leavePage()', 1000)">

 

 

 

<table width="340" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="70">  </td>

<td width="258"> </td>

</tr>

<tr valign="middle" align="center"

>

<td colspan="2" height="138" class="9P">

<p>大家快跑!!要爆炸了!!还有<span id="countdown"> <!-- Output initial amount of time. -->

<script language="JavaScript">

document.write(intLeft);

 

</script>

</span> 秒就要爆炸了!!快!!</p>

</td>

</tr>

</table>

</body>

</html>

 

 

0 Comments

Wed

18

Mar

2009

34、超酷的时间日期类倒记时

34、超酷的时间日期类倒记时

<head>

<script language="JavaScript">

<!-- hide script from old browser

var DifferenceHour = -1

var DifferenceMinute = -1

var DifferenceSecond = -1

var Tday = new Date("July 20, 2001 00:00:00")

var daysms = 24 * 60 * 60 * 1000

var hoursms = 60 * 60 * 1000

var Secondms = 60 * 1000

var microsecond = 1000

function clock()

{

var time = new Date()

var hour = time.getHours()

var minute = time.getMinutes()

var second = time.getSeconds()

var timevalue = ""+((hour > 12) ? hour-12:hour)

timevalue +=((minute < 10) ? ":0":":")+minute

timevalue +=((second < 10) ? ":0":":")+second

timevalue +=((hour >12 ) ? " PM":" AM")

// document.formnow.now.value = timevalue

var convertHour = DifferenceHour

var convertMinute = DifferenceMinute

var convertSecond = DifferenceSecond

var Diffms = Tday.getTime() - time.getTime()

DifferenceHour = Math.floor(Diffms / daysms)

Diffms -= DifferenceHour * daysms

DifferenceMinute = Math.floor(Diffms / hoursms)

Diffms -= DifferenceMinute * hoursms

DifferenceSecond = Math.floor(Diffms / Secondms)

Diffms -= DifferenceSecond * Secondms

var dSecs = Math.floor(Diffms / microsecond)

if(convertHour != DifferenceHour) document.formnow.dd.value=DifferenceHour

if(convertMinute != DifferenceMinute) document.formnow.hh.value=DifferenceMinute

if(convertSecond != DifferenceSecond) document.formnow.mm.value=DifferenceSecond

document.formnow.ss.value=dSecs

// document.formnow.Tnow.value= DifferenceHour DifferenceMinute + DifferenceSecond + dSecs

setTimeout("clock()",1000)

}

// end hiding -->

</script>

</head>

<body onload="clock();return true">

<form name="formnow"> 现在离2001july 20还有

<input type="text" name="dd" size=2>

<input type="text" name="hh" size=2> 小时

<input type="text" name="mm" size=2>

<input type="text" name="ss" size=2>

</form>

 

 

0 Comments

Wed

18

Mar

2009

33、跟随鼠标的 时钟代码

33、跟随鼠标的 时钟代码

脚本说明:

把如下代码加入<body>区域中

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

colors = new Array('330099','00ff00','ff00ff');  //Clock face colors.

sCol = 'ff00ff';  //seconds colour.

mCol = '00ff00';  //minutes colour.

hCol = '330099';  //hours colour.

//Alter nothing below!

H = 'Hours..';

H = H.split('');

H = H.reverse();

M = 'Minutes..';

M = M.split('');

M = M.reverse();

S = 'Seconds..';

S = S.split('');

S = S.reverse();

dots = 12;

var Ypos = 0,Xpos = 0,Ybase = 0,Xbase = 0;

var ay = 0, ax = 0, Ay = 0, Ax = 0, by = 0, bx = 0, By = 0, Bx = 0, cy = 0, cx = 0, Cy = 0, Cx = 0, dy = 0, dx = 0, Dy = 0, Dx = 0;

count = 0;

count_a = 0;

move = 1;

ns = (document.layers)?1:0;

viz = (document.layers)?'hide':'hidden';

if (ns) {

for (i = 0; i < dots; i++)

document.write('<layer name=nface'+i+' top=0 left=0 bgcolor=#ffffff clip="0,0,3,3"></layer>');

for (i = 0; i < S.length; i++)

document.write('<layer name=nx'+i+' top=0 left=0 width=36 height=36><font face=Verdana size=2 color='+sCol+'><center>'+S[i]+'</center></font></layer>');

for (i = 0; i < M.length; i++)

document.write('<layer name=ny'+i+' top=0 left=0 width=36 height=36><font face=Verdana size=2 color='+mCol+'><center>'+M[i]+'</center></font></layer>');

for (i = 0; i < H.length; i++)

document.write('<layer name=nz'+i+' top=0 left=0 width=36 height=36><font face=Verdana size=2 color='+hCol+'><center>'+H[i]+'</center></font></layer>');

}

else{

document.write('<div id="W" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i = 0; i < dots; i++) {

document.write('<div id="face" style="position:absolute;top:0px;left:0px;width:3px;height:3px;font-size:3px;background:#ffffff"></div>');

}

document.write('</div></div>');

document.write('<div id="X" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i = 0; i < S.length; i++) {

document.write('<div id="x" style="position:absolute;width:36px;height:36px;font-family:Verdana;font-size:12px;color:'+sCol+';text-align:center;padding-top:10px">'+S[i]+'</div>');

}

document.write('</div></div>')

document.write('<div id="Y" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i = 0; i < M.length; i++) {

document.write('<div id="y" style="position:absolute;width:36px;height:36px;font-family:Verdana;font-size:12px;color:'+mCol+';text-align:center;padding-top:10px">'+M[i]+'</div>');

}

document.write('</div></div>')

document.write('<div id="Z" style="position:absolute;top:0px;left:0px"><div style="position:relative">');

for (i = 0; i < H.length; i++) {

document.write('<div id="z" style="position:absolute;width:36px;height:36px;font-family:Verdana;font-size:12px;color:'+hCol+';text-align:center;padding-top:10px">'+H[i]+'</div>');

}

document.write('</div></div>');

}

if (ns) {

window.captureEvents(Event.MOUSEMOVE);

function nsMouse(evnt) {

Ypos = evnt.pageY + 100;

Xpos = evnt.pageX + 100;

}

window.onMouseMove = nsMouse;

}

else{

function ieMouse() {

Ypos = event.y + 100;

Xpos = event.x + 100;

}

document.onmousemove = ieMouse;

}

function clock() {

time = new Date ();

secs = time.getSeconds();

sec = -1.57 + Math.PI * secs / 30;

mins = time.getMinutes();

min = -1.57 + Math.PI * mins / 30;

hr = time.getHours();

hrs = -1.575 + Math.PI * hr / 6 + Math.PI * parseInt(time.getMinutes()) / 360;

Ybase = 15;

Xbase = 15;

if (ns) {

document.layers["nx"+0].visibility = viz;

document.layers["ny"+0].visibility = viz;

document.layers["nz"+0].visibility = viz;

for (i = 0; i < S.length; i++) {

document.layers["nx"+i].top = ay - 12 + (i * Ybase) * Math.sin(sec);

document.layers["nx"+i].left = ax - 12 + (i * Xbase) * Math.cos(sec);

}

for (i = 0; i < M.length; i++) {

document.layers["ny"+i].top = by - 12 + (i * Ybase) * Math.sin(min);

document.layers["ny"+i].left = bx - 12 + (i * Xbase) * Math.cos(min);

}

for (i = 0; i < H.length; i++) {

document.layers["nz"+i].top = cy - 12 + (i * Ybase) * Math.sin(hrs);

document.layers["nz"+i].left = cx - 12 + (i * Xbase) * Math.cos(hrs);

}

for (i = 0; i < dots; ++i) {

document.layers["nface"+i].top = dy - 2 + (70 * Math.sin(-0.49+dots+i/1.9));

document.layers["nface"+i].left = dx + 4 + (70 * Math.cos(-0.49+dots+i/1.9));

   }

}

else {

var scrll = document.body.scrollTop;

W.style.pixelTop = scrll;

X.style.pixelTop = scrll;

Y.style.pixelTop = scrll;

Z.style.pixelTop = scrll;

x[0].style.visibility=viz;

y[0].style.visibility = viz;

z[0].style.visibility = viz;

for (i = 0; i < S.length; i++) {

x[i].style.pixelTop = ay - 12 + (i * Ybase) * Math.sin(sec);

x[i].style.pixelLeft = ax - 12 + (i * Xbase) * Math.cos(sec);

}

for (i = 0; i < M.length; i++) {

y[i].style.pixelTop = by - 12 + (i * Ybase) * Math.sin(min);

y[i].style.pixelLeft = bx - 12 + (i * Xbase) * Math.cos(min);

}

for (i = 0; i < H.length; i++) {

z[i].style.pixelTop = cy - 12 + (i * Ybase) * Math.sin(hrs);

z[i].style.pixelLeft = cx - 12 + (i * Xbase) * Math.cos(hrs);

}

for (i = 0; i < dots; ++i) {

face[i].style.pixelTop = dy + 6 + (70 * Math.sin(-0.49 + dots + i / 1.9));

face[i].style.pixelLeft = dx + 4 + (70 * Math.cos(-0.49 + dots + i / 1.9));

      }

   }

}

function MouseFollow() {

ay = Math.round(Ay += ((Ypos) - Ay) * 4 / 15);

ax = Math.round(Ax += ((Xpos) - Ax) * 4 / 15);

by = Math.round(By += (ay - By) * 4 / 15);

bx = Math.round(Bx += (ax - Bx) * 4 / 15);

cy = Math.round(Cy += (by - Cy) * 4 / 15);

cx = Math.round(Cx += (bx - Cx) * 4 / 15);

dy = Math.round(Dy += (cy - Dy) * 4 / 15);

dx = Math.round(Dx += (cx - Dx) * 4 / 15);

clock();

setTimeout('MouseFollow()',10);

}

function colorstep() {

count +=move;

if (count >= dots) {count=0;count_a += move}

if (count_a == colors.length) count_a = 0;

if (ns) document.layers["nface"+count].bgColor = colors[count_a];

else face[count].style.background = colors[count_a];

setTimeout('colorstep()',100)

}

function StartAll() {

MouseFollow();

colorstep();

}

if (document.layers || document.all) window.onload = StartAll;

//  End -->

</script>v

 

 

0 Comments

Wed

18

Mar

2009

32、非常酷的时钟代码

32、非常酷的时钟代码

脚本说明:

把如下代码加入<body>区域中

<STYLE type=text/css>.light {

       FILTER: Light

}

.date {

       COLOR: #000000; FONT-FAMILY: "Geneva", "Arial", "Helvetica", "san-serif"; FONT-SIZE: 12px; FONT-WEIGHT: bold; TEXT-ALIGN: center

}

</STYLE>

 

<SCRIPT>

function setLights(){

       var sx=Math.cos(slightDir)*slightr;

       var sy=Math.sin(slightDir)*slightr;

       var mx=Math.cos(mlightDir)*mlightr;

       var my=Math.sin(mlightDir)*mlightr;

       var hx=Math.cos(hlightDir)*hlightr;

       var hy=Math.sin(hlightDir)*hlightr;

       sconDiv.filters.Light.clear();

       sconDiv.filters.Light.addCone(sx+72,sy+72,1,73,72,215,255,5,20,1);

       sconDiv.filters.Light.addCone(mx+72,my+72,1,73,72,255,10,0,20,2);

       sconDiv.filters.Light.addCone(hx+72,hy+72,1,73,72,15,100,255,20,4);

       sconDiv.filters.Light.addAmbient(155,155,155,100);

}

 

function timeGo(){

       var tt=new Date();

       slightDir=(tt.getSeconds())/60*6.28-1.57;

       mlightDir=(tt.getMinutes())/60*6.28-1.57;

       hlightDir=(tt.getHours())/12*6.28-1.57+mlightDir/6.28*0.52+0.05;

       dateDiv.innerText=tt.getMonth()+1+"-"+tt.getDate();

       setLights();

}

 

function InitClock(){

       slightr=110;

       mlightr=90;

       hlightr=60;

       timeGo();

       setInterval("timeGo()",1000);

}

window.onload=InitClock;

</SCRIPT>

 

<DIV id=clockDiv

style="HEIGHT: 222px; LEFT: 145px; POSITION: absolute; TOP: 12px; WIDTH: 233px; Z-INDEX: 1">

<DIV class=light id=sconDiv

style="HEIGHT: 70px; LEFT: 27px; POSITION: absolute; TOP: 22px; WIDTH: 70px; Z-INDEX: 1"><IMG

height=144 src="image/clockm.gif" width=144></DIV><IMG height=200

src="image/clock2.gif" width=200>

<DIV id=clLayer

style="HEIGHT: 25px; LEFT: 88px; POSITION: absolute; TOP: 80px; WIDTH: 25px; Z-INDEX: 2"><IMG

height=26 src="image/clockd.gif" width=26></DIV>

<DIV class=date id=dateDiv

style="HEIGHT: 16px; LEFT: 85px; POSITION: absolute; TOP: 178px; WIDTH: 32px; Z-INDEX: 3">12-2</DIV></DIV>

 

 

0 Comments

Wed

18

Mar

2009

31、多功能的时间代码

31、多功能的时间代码

<html>

 

<head>

 

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>网页特效代码--又一款日期输入控件,可以输入当前的时间</title>

</head>

 

<body>

 

<form name="form1" method="post" action="">

  <p>

    <input type="text" name="textfield"  onFocus="CalendarWebControl.show(this,true,this.value);">

    日期时间输入</p>

  <p>

    <input type="text" name="textfield2" onFocus="CalendarWebControl.show(this,false,this.value);">

日期输入</p>

</form>

 

<script language="javascript">

function atCalendarControl(){

  var calendar=this;

  this.calendarPad=null;

  this.prevMonth=null;

  this.nextMonth=null;

  this.prevYear=null;

  this.nextYear=null;

  this.goToday=null;

  this.calendarClose=null;

  this.calendarAbout=null;

  this.head=null;

  this.body=null;

  this.today=[];

  this.currentDate=[];

  this.sltDate;

  this.target;

  this.source;

 

  /************** 加入日历底板及阴影 *********************/

  this.addCalendarPad=function(){

   document.write("<div id='divCalendarpad' style='position:absolute;top:100;left:0;width:255;height:187;display:none;'>");

   document.write("<iframe frameborder=0 height=189 width=250></iframe>");

   document.write("<div style='position:absolute;top:2;left:2;width:250;height:187;background-color:#336699;'></div>");

   document.write("</div>");

   calendar.calendarPad=document.all.divCalendarpad;

  }

  /************** 加入日历面板 *********************/

  this.addCalendarBoard=function(){

   var BOARD=this;

   var divBoard=document.createElement("div");

   calendar.calendarPad.insertAdjacentElement("beforeEnd",divBoard);

   divBoard.style.cssText="position:absolute;top:0;left:0;width:250;height:187;border:0 outset;background-color:buttonface;";

 

   var tbBoard=document.createElement("table");

   divBoard.insertAdjacentElement("beforeEnd",tbBoard);

   tbBoard.style.cssText="position:absolute;top:2;left:2;width:248;height:10;font-size:9pt;";

   tbBoard.cellPadding=0;

   tbBoard.cellSpacing=1;

 

  /************** 设置各功能按钮的功能 *********************/

   /*********** Calendar About Button ***************/

   trRow = tbBoard.insertRow(0);

   calendar.calendarAbout=calendar.insertTbCell(trRow,0,"-","center");

   calendar.calendarAbout.title="帮助 快捷键:H";

   calendar.calendarAbout.onclick=function(){calendar.about();}

   /*********** Calendar Head ***************/

   tbCell=trRow.insertCell(1);

   tbCell.colSpan=5;

   tbCell.bgColor="#99CCFF";

   tbCell.align="center";

   tbCell.style.cssText = "cursor:default";

   calendar.head=tbCell;

   /*********** Calendar Close Button ***************/

   tbCell=trRow.insertCell(2);

   calendar.calendarClose = calendar.insertTbCell(trRow,2,"x","center");

   calendar.calendarClose.title="关闭 快捷键:ESCX";

   calendar.calendarClose.onclick=function(){calendar.hide();}

 

   /*********** Calendar PrevYear Button ***************/

   trRow = tbBoard.insertRow(1);

   calendar.prevYear = calendar.insertTbCell(trRow,0,"<<","center");

   calendar.prevYear.title="上一年 快捷键:";

   calendar.prevYear.onmousedown=function(){

    calendar.currentDate[0]--;

    calendar.show(calendar.target,calendar.returnTime,calendar.currentDate[0]+"-"+calendar.formatTime(calendar.currentDate[1])+"-"+calendar.formatTime(calendar.currentDate[2]),calendar.source);

   }

   /*********** Calendar PrevMonth Button ***************/

   calendar.prevMonth = calendar.insertTbCell(trRow,1,"<","center");

   calendar.prevMonth.title="上一月 快捷键:";

   calendar.prevMonth.onmousedown=function(){

    calendar.currentDate[1]--;

    if(calendar.currentDate[1]==0){

     calendar.currentDate[1]=12;

     calendar.currentDate[0]--;

    }

    calendar.show(calendar.target,calendar.returnTime,calendar.currentDate[0]+"-"+calendar.formatTime(calendar.currentDate[1])+"-"+calendar.formatTime(calendar.currentDate[2]),calendar.source);

   }

   /*********** Calendar Today Button ***************/

   calendar.goToday = calendar.insertTbCell(trRow,2,"今天","center",3);

   calendar.goToday.title="选择今天 快捷键:T";

   calendar.goToday.onclick=function(){

        if(calendar.returnTime) 

           calendar.sltDate=calendar.today[0]+"-"+calendar.formatTime(calendar.today[1])+"-"+calendar.formatTime(calendar.today[2])+" "+calendar.formatTime(calendar.today[3])+":"+calendar.formatTime(calendar.today[4])

        else

           calendar.sltDate=calendar.today[0]+"-"+calendar.formatTime(calendar.today[1])+"-"+calendar.formatTime(calendar.today[2]);

    calendar.target.value=calendar.sltDate;

    calendar.hide();

    //calendar.show(calendar.target,calendar.today[0]+"-"+calendar.today[1]+"-"+calendar.today[2],calendar.source);

   }

   /*********** Calendar NextMonth Button ***************/

   calendar.nextMonth = calendar.insertTbCell(trRow,3,">","center");

   calendar.nextMonth.title="下一月 快捷键:";

   calendar.nextMonth.onmousedown=function(){

    calendar.currentDate[1]++;

    if(calendar.currentDate[1]==13){

     calendar.currentDate[1]=1;

     calendar.currentDate[0]++;

    }

    calendar.show(calendar.target,calendar.returnTime,calendar.currentDate[0]+"-"+calendar.formatTime(calendar.currentDate[1])+"-"+calendar.formatTime(calendar.currentDate[2]),calendar.source);

   }

   /*********** Calendar NextYear Button ***************/

   calendar.nextYear = calendar.insertTbCell(trRow,4,">>","center");

   calendar.nextYear.title="下一年 快捷键:";

   calendar.nextYear.onmousedown=function(){

    calendar.currentDate[0]++;

    calendar.show(calendar.target,calendar.returnTime,calendar.currentDate[0]+"-"+calendar.formatTime(calendar.currentDate[1])+"-"+calendar.formatTime(calendar.currentDate[2]),calendar.source);

 

   }

 

   trRow = tbBoard.insertRow(2);

   var cnDateName = new Array("","","","","","","");

   for (var i = 0; i < 7; i++) {

    tbCell=trRow.insertCell(i)

    tbCell.innerText=cnDateName[i];

    tbCell.align="center";

    tbCell.width=35;

    tbCell.style.cssText="cursor:default;border:1 solid #99CCCC;background-color:#99CCCC;";

   }

 

   /*********** Calendar Body ***************/

   trRow = tbBoard.insertRow(3);

   tbCell=trRow.insertCell(0);

   tbCell.colSpan=7;

   tbCell.height=97;

   tbCell.vAlign="top";

   tbCell.bgColor="#F0F0F0";

  

   var tbBody=document.createElement("table");

   tbCell.insertAdjacentElement("beforeEnd",tbBody);

   tbBody.style.cssText="position:relative;top:0;left:0;width:245;height:103;font-size:9pt;"

   tbBody.cellPadding=0;

   tbBody.cellSpacing=1;

   calendar.body=tbBody;

      

   /*********** Time Body ***************/

   trRow = tbBoard.insertRow(4);

   tbCell=trRow.insertCell(0);

   calendar.prevHours = calendar.insertTbCell(trRow,0,"-","center");

   calendar.prevHours.title="小时调整 快捷键:Home";

   calendar.prevHours.onmousedown=function(){

              calendar.currentDate[3]--;

              if(calendar.currentDate[3]==-1) calendar.currentDate[3]=23;

              calendar.bottom.innerText=calendar.formatTime(calendar.currentDate[3])+":"+calendar.formatTime(calendar.currentDate[4]);

       }

   tbCell=trRow.insertCell(1);

   calendar.nextHours = calendar.insertTbCell(trRow,1,"+","center");

   calendar.nextHours.title="小时调整 快捷键:End";

   calendar.nextHours.onmousedown=function(){

              calendar.currentDate[3]++;

              if(calendar.currentDate[3]==24) calendar.currentDate[3]=0;

              calendar.bottom.innerText=calendar.formatTime(calendar.currentDate[3])+":"+calendar.formatTime(calendar.currentDate[4]);

       }

   tbCell=trRow.insertCell(2);

   tbCell.colSpan=3;

   tbCell.bgColor="#99CCFF";

   tbCell.align="center";

   tbCell.style.cssText = "cursor:default";

   calendar.bottom=tbCell;

   tbCell=trRow.insertCell(3);

   calendar.prevMinutes = calendar.insertTbCell(trRow,3,"-","center");

   calendar.prevMinutes.title="分钟调整 快捷键:PageUp";

   calendar.prevMinutes.onmousedown=function(){

              calendar.currentDate[4]--;

              if(calendar.currentDate[4]==-1) calendar.currentDate[4]=59;

              calendar.bottom.innerText=calendar.formatTime(calendar.currentDate[3])+":"+calendar.formatTime(calendar.currentDate[4]);

       }

   tbCell=trRow.insertCell(4);

   calendar.nextMinutes = calendar.insertTbCell(trRow,4,"+","center");

   calendar.nextMinutes.title="分钟调整 快捷键:PageDown";

   calendar.nextMinutes.onmousedown=function(){

              calendar.currentDate[4]++;

              if(calendar.currentDate[4]==60) calendar.currentDate[4]=0;

              calendar.bottom.innerText=calendar.formatTime(calendar.currentDate[3])+":"+calendar.formatTime(calendar.currentDate[4]);

       }

 

}

 

/************** 加入功能按钮公共样式 *********************/

  this.insertTbCell=function(trRow,cellIndex,TXT,trAlign,tbColSpan){

   var tbCell=trRow.insertCell(cellIndex);

   if(tbColSpan!=undefined) tbCell.colSpan=tbColSpan;

 

   var btnCell=document.createElement("button");

   tbCell.insertAdjacentElement("beforeEnd",btnCell);

   btnCell.value=TXT;

   btnCell.style.cssText="width:100%;border:1 outset;background-color:buttonface;";

   btnCell.onmouseover=function(){

   btnCell.style.cssText="width:100%;border:1 outset;background-color:#F0F0F0;";

 

   }

   btnCell.onmouseout=function(){

    btnCell.style.cssText="width:100%;border:1 outset;background-color:buttonface;";

   }

  // btnCell.onmousedown=function(){

  //  btnCell.style.cssText="width:100%;border:1 inset;background-color:#F0F0F0;";

  // }

   btnCell.onmouseup=function(){

    btnCell.style.cssText="width:100%;border:1 outset;background-color:#F0F0F0;";

   }

   btnCell.onclick=function(){

    btnCell.blur();

   }

   return btnCell;

  }

 

  this.setDefaultDate=function(){

   var dftDate=new Date();

   calendar.today[0]=dftDate.getYear();

   calendar.today[1]=dftDate.getMonth()+1;

   calendar.today[2]=dftDate.getDate();

   calendar.today[3]=dftDate.getHours();

   calendar.today[4]=dftDate.getMinutes();

  }

 

  /****************** Show Calendar *********************/

  this.show=function(targetObject,returnTime,defaultDate,sourceObject){

   if(targetObject==undefined) {

    alert("未设置目标对象. \n方法: ATCALENDAR.show(obj 目标对象,boolean 是否返回时间,string 默认日期,obj 点击对象);\n\n目标对象:接受日期返回值的对象.\n默认日期:格式为\"yyyy-mm-dd\",缺省为当前日期.\n点击对象:点击这个对象弹出calendar,默认为目标对象.\n");

    return false;

   }

   else calendar.target=targetObject;

  

   if(sourceObject==undefined) calendar.source=calendar.target;

   else calendar.source=sourceObject;

 

   if(returnTime) calendar.returnTime=true;

   else calendar.returnTime=false;

 

   var firstDay;

   var Cells=new Array();

   if((defaultDate==undefined) || (defaultDate=="")){

    var theDate=new Array();

    calendar.head.innerText = calendar.today[0]+"-"+calendar.formatTime(calendar.today[1])+"-"+calendar.formatTime(calendar.today[2]);

    calendar.bottom.innerText = calendar.formatTime(calendar.today[3])+":"+calendar.formatTime(calendar.today[4]);

      

    theDate[0]=calendar.today[0]; theDate[1]=calendar.today[1]; theDate[2]=calendar.today[2];

       theDate[3]=calendar.today[3]; theDate[4]=calendar.today[4];

   }

   else{

    var Datereg=/^\d{4}-\d{1,2}-\d{2}$/

    var DateTimereg=/^(\d{1,4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2})$/

    if((!defaultDate.match(Datereg)) && (!defaultDate.match(DateTimereg))){

     alert("默认日期(时间)的格式不正确!\t\n\n默认可接受格式为:\n1yyyy-mm-dd \n2yyyy-mm-dd hh:mm\n3()");

        calendar.setDefaultDate();

     return;

    }

      

       if(defaultDate.match(Datereg)) defaultDate=defaultDate+" "+calendar.today[3]+":"+calendar.today[4];

       var strDateTime=defaultDate.match(DateTimereg);

       var theDate=new Array(4)

       theDate[0]=strDateTime[1];

       theDate[1]=strDateTime[2];

       theDate[2]=strDateTime[3];

       theDate[3]=strDateTime[4];

       theDate[4]=strDateTime[5];

    calendar.head.innerText = theDate[0]+"-"+calendar.formatTime(theDate[1])+"-"+calendar.formatTime(theDate[2]);

    calendar.bottom.innerText = calendar.formatTime(theDate[3])+":"+calendar.formatTime(theDate[4]);

       }

   calendar.currentDate[0]=theDate[0];

   calendar.currentDate[1]=theDate[1];

   calendar.currentDate[2]=theDate[2];

   calendar.currentDate[3]=theDate[3];

   calendar.currentDate[4]=theDate[4];

  

   theFirstDay=calendar.getFirstDay(theDate[0],theDate[1]);

   theMonthLen=theFirstDay+calendar.getMonthLen(theDate[0],theDate[1]);

   //calendar.setEventKey();

 

   calendar.calendarPad.style.display="";

   var theRows = Math.ceil((theMonthLen)/7);

   //清除旧的日历;

   while (calendar.body.rows.length > 0) {

    calendar.body.deleteRow(0)

   }

   //建立新的日历;

   var n=0;day=0;

   for(i=0;i<theRows;i++){

    theRow=calendar.body.insertRow(i);

    for(j=0;j<7;j++){

     n++;

     if(n>theFirstDay && n<=theMonthLen){

      day=n-theFirstDay;

      calendar.insertBodyCell(theRow,j,day);

     }

 

     else{

      var theCell=theRow.insertCell(j);

      theCell.style.cssText="background-color:#F0F0F0;cursor:default;";

     }

    }

   }

 

   //****************调整日历位置**************//

   var offsetPos=calendar.getAbsolutePos(calendar.source);//计算对象的位置;

   if((document.body.offsetHeight-(offsetPos.y+calendar.source.offsetHeight-document.body.scrollTop))<calendar.calendarPad.style.pixelHeight){

    var calTop=offsetPos.y-calendar.calendarPad.style.pixelHeight;

   }

   else{

    var calTop=offsetPos.y+calendar.source.offsetHeight;

   }

   if((document.body.offsetWidth-(offsetPos.x+calendar.source.offsetWidth-document.body.scrollLeft))>calendar.calendarPad.style.pixelWidth){

    var calLeft=offsetPos.x;

   }

   else{

    var calLeft=calendar.source.offsetLeft+calendar.source.offsetWidth;

   }

   //alert(offsetPos.x);

   calendar.calendarPad.style.pixelLeft=calLeft;

   calendar.calendarPad.style.pixelTop=calTop;

  }

  /****************** 计算对象的位置 *************************/

  this.getAbsolutePos = function(el) {

   var r = { x: el.offsetLeft, y: el.offsetTop };

   if (el.offsetParent) {

    var tmp = calendar.getAbsolutePos(el.offsetParent);

    r.x += tmp.x;

    r.y += tmp.y;

   }

   return r;

  };

 

  //************* 插入日期单元格 **************/

  this.insertBodyCell=function(theRow,j,day,targetObject){

   var theCell=theRow.insertCell(j);

   if(j==0) var theBgColor="#FF9999";

   else var theBgColor="#FFFFFF";

   if(day==calendar.currentDate[2]) var theBgColor="#CCCCCC";

   if(day==calendar.today[2]) var theBgColor="#99FFCC";

   theCell.bgColor=theBgColor;

   theCell.innerText=day;

   theCell.align="center";

   theCell.width=35;

   theCell.style.cssText="border:1 solid #CCCCCC;cursor:hand;";

   theCell.onmouseover=function(){

    theCell.bgColor="#FFFFCC";

    theCell.style.cssText="border:1 outset;cursor:hand;";

   }

   theCell.onmouseout=function(){

    theCell.bgColor=theBgColor;

    theCell.style.cssText="border:1 solid #CCCCCC;cursor:hand;";

   }

   theCell.onmousedown=function(){

    theCell.bgColor="#FFFFCC";

    theCell.style.cssText="border:1 inset;cursor:hand;";

   }

   theCell.onclick=function(){

        if(calendar.returnTime) 

           calendar.sltDate=calendar.currentDate[0]+"-"+calendar.formatTime(calendar.currentDate[1])+"-"+calendar.formatTime(day)+" "+calendar.formatTime(calendar.currentDate[3])+":"+calendar.formatTime(calendar.currentDate[4])

        else

           calendar.sltDate=calendar.currentDate[0]+"-"+calendar.formatTime(calendar.currentDate[1])+"-"+calendar.formatTime(day);

    calendar.target.value=calendar.sltDate;

    calendar.hide();

   }

  }

  /************** 取得月份的第一天为星期几 *********************/

  this.getFirstDay=function(theYear, theMonth){

   var firstDate = new Date(theYear,theMonth-1,1);

   return firstDate.getDay();

  }

  /************** 取得月份共有几天 *********************/

 

  this.getMonthLen=function(theYear, theMonth) {

   theMonth--;

   var oneDay = 1000 * 60 * 60 * 24;

   var thisMonth = new Date(theYear, theMonth, 1);

   var nextMonth = new Date(theYear, theMonth + 1, 1);

   var len = Math.ceil((nextMonth.getTime() - thisMonth.getTime())/oneDay);

   return len;

  }

  /************** 隐藏日历 *********************/

  this.hide=function(){

   //calendar.clearEventKey();

   calendar.calendarPad.style.display="none";

  

  }

  /************** 从这里开始 *********************/

  this.setup=function(defaultDate){

   calendar.addCalendarPad();

   calendar.addCalendarBoard();

   calendar.setDefaultDate();

  }

  /************** 格式化时间 *********************/

 this.formatTime = function(str) {

  str = ("00"+str);

  return str.substr(str.length-2);

 }

 

/************** 关于AgetimeCalendar *********************/

  this.about=function(){

   var strAbout = "\nWeb 日历选择输入控件操作说明:\n\n";

   strAbout+="-\t: 关于\n";

   strAbout+="x\t: 隐藏\n";

   strAbout+="<<\t: 上一年\n";

   strAbout+="<\t: 上一月\n";

 

   strAbout+="今日\t: 返回当天日期\n";

   strAbout+=">\t: 下一月\n";

   strAbout+="<<\t: 下一年\n";

   strAbout+="\nWeb日历选择输入控件\tVer:v1.0\t\nDesigned By:wxb \t\t2004.11.22\t\n";

   alert(strAbout);

  }

 

document.onkeydown=function(){

       if(calendar.calendarPad.style.display=="none"){

              window.event.returnValue= true;

              return true ;

       }

       switch(window.event.keyCode){

              case 27 : calendar.hide(); break; //ESC

              case 37 : calendar.prevMonth.onmousedown(); break;//

              case 38 : calendar.prevYear.onmousedown();break; //

              case 39 : calendar.nextMonth.onmousedown(); break;//

              case 40 : calendar.nextYear.onmousedown(); break;//

              case 84 : calendar.goToday.onclick(); break;//T

              case 88 : calendar.hide(); break;   //X

              case 72 : calendar.about(); break;   //H      

              case 36 : calendar.prevHours.onmousedown(); break;//Home

              case 35 : calendar.nextHours.onmousedown(); break;//End

              case 33 : calendar.prevMinutes.onmousedown();break; //PageUp

              case 34 : calendar.nextMinutes.onmousedown(); break;//PageDown

              }

              window.event.keyCode = 0;

              window.event.returnValue= false;

              }

 

  calendar.setup();

 }

 

var CalendarWebControl = new atCalendarControl();

</script>

 

</body>

 

</html>

 

0 Comments