- 浏览: 321563 次
- 性别:
文章分类
最新评论
-
i042416:
分析在哪?
angular分析 -
何盆盆:
你好,请问您这是Extjs3还是Extjs4
ExtJs源码分析与学习—ExtJs事件机制(一) -
124753561:
引用引用引用引用引用[u][u][u][u][i][i][i] ...
Subvision SVN 服务端与客户端的安装 -
谷超:
请问一下例子中itext是什么版本的?
利用iText生成word文档例子参考 -
geosmart:
正好要用到执行字符串中方法,学习了
java中利用反射机制实现调用给定为字符串的方法名
// JavaScript Document
/********************************************************************
主题:基于CSS&LI的日历显示
作者:Smart/Issac
说明:
1.调用GetCalendar(InputBoxId);
2.问题:IE5下隐含框架zIndex属性不支持;Mozilla下尚不支持若干方法.
********************************************************************/
/*创建框架*/
document.writeln("<div id=\"calendar\"></div>");
document.writeln("<iframe id=\"calendarBox\" scrolling=\"no\" frameborder=\"0\" style=\"display:none; position:absolute;\"></iframe>");
var cDiv = document.getElementById("calendar");
var cFrame = document.getElementById("calendarBox");
/*基本参数*/
var meWidth = cDiv.clientWidth; //日历宽度
var meHeight= cDiv.clientHeight; //日历高度
var isHidden=true; //日历是否关闭
/*取得今日日期*/
function GetTodayDate() {
today=new Date();
yy=today.getYear();
mm=(today.getMonth() + 1);
if (mm<10)
mm='0'+mm;
dd=today.getDate();
if (dd<10)
dd='0'+dd;
return yy+'-'+mm+'-'+dd
}
/*输入今天日期*/
function SetTodayDate(InputBoxId) {
HiddenCalendar();
document.getElementById(InputBoxId).value=GetTodayDate();
}
/*取某年某月第一天的星期值(月份-1)*/
function GetFirstWeek(theYear,theMonth) {
return (new Date(theYear,theMonth-1,1)).getDay();
}
/*取某年某月中总天数*/
function GetThisDays(theYear,theMonth) {
return (new Date(theYear,theMonth,0)).getDate();
}
/*取某年某月上个月中总天数*/
function GetLastDays(theYear,theMonth) {
return (new Date(theYear,theMonth-1,0)).getDate();
}
/*判断是否是闰年*/
function LeapYear(theYear) {
if ((theYear%400==0) || ((theYear%4==0) && (theYear%100!=0)))
return true;
else
return false;
}
/*判断日期(YYYY-MM-DD)的日期是否正确*/
function DateIsTrue(asDate) {
var lsDate=asDate + "";
var loDate=lsDate.split("-");
if (loDate.length!=3)
return false;
var liYear=parseFloat(loDate[0]);
var liMonth=parseFloat(loDate[1]);
var liDay=parseFloat(loDate[2]);
if ((loDate[0].length>4)||(loDate[1].length>2)||(loDate[2].length>2))
return false;
if (isNaN(liYear)||isNaN(liMonth)||isNaN(liDay))
return false;
if ((liYear<1800)||(liYear>2500))
return false;
if ((liMonth>12)||(liMonth<=0))
return false;
if (GetThisDays(liYear,liMonth)<liDay)
return false;
return !isNaN(Date.UTC(liYear,liMonth,liDay));
}
/*输入框显示*/
function InputValue(InputBoxId,Year,Month,Day) {
if (Month<10)
Month='0'+Month;
if (Day<10)
Day='0'+Day;
document.getElementById(InputBoxId).value=Year+"-"+Month+"-"+Day;
}
/*上一月*/
function PrevMonth(InputBoxId,Year,Month,Day) {
Month=Month-1;
if (Month<1) {
Month=12;
Year=Year-1;
if (Year<1800)
Year=2500;
}
Day=((GetThisDays(Year,Month)<Day)?GetThisDays(Year,Month):Day);
isHidden=false;
ShowCalendar(InputBoxId,Year,Month,Day);
}
/*下一月*/
function NextMonth(InputBoxId,Year,Month,Day) {
Month=Month+1;
if (Month>12) {
Month=1;
Year=Year+1;
if (Year>2500)
Year=1800;
}
Day=((GetThisDays(Year,Month)<Day)?GetThisDays(Year,Month):Day);
isHidden=false;
ShowCalendar(InputBoxId,Year,Month,Day);
}
/*上一年*/
function PrevYear(InputBoxId,Year,Month,Day) {
Year=Year-1;
if (Year<1800)
Year=2500;
Day=((GetThisDays(Year,Month)<Day)?GetThisDays(Year,Month):Day);
isHidden=false;
ShowCalendar(InputBoxId,Year,Month,Day);
}
/*下一年*/
function NextYear(InputBoxId,Year,Month,Day) {
Year=Year+1;
if (Year>2500)
Year=1800;
Day=((GetThisDays(Year,Month)<Day)?GetThisDays(Year,Month):Day);
isHidden=false;
ShowCalendar(InputBoxId,Year,Month,Day);
}
/*根据输入框中的日期显示日历(调用方法)*/
function GetCalendar(InputBoxId) {
isHidden=false;
var boxValue=document.getElementById(InputBoxId).value;
if (DateIsTrue(boxValue)) {
loDate=boxValue.split("-");
YY=parseFloat(loDate[0]);
MM=parseFloat(loDate[1]);
DD=parseFloat(loDate[2]);
ShowCalendar(InputBoxId,YY,MM,DD);
}
else {
today=new Date();
yy=today.getYear();
mm=(today.getMonth() + 1);
dd=today.getDate();
ShowCalendar(InputBoxId,yy,mm,dd);
}
}
/*隐藏日历*/
function HiddenCalendar() {
cDiv.style.display="none";
cFrame.style.display = "none";
}
function CloseCalendar() {
if (isHidden){
cDiv.style.display="none";
cFrame.style.display = "none";
}
isHidden=true;
}
/*显示日历*/
function ShowCalendar(InputBoxId,theYear,theMonth,theDay) {
var nowYear=(theYear==null?1981:theYear);
var nowMonth=(theMonth==null?10:theMonth);
var nowDay=(theDay==null?7:theDay);
var fw=GetFirstWeek(nowYear,nowMonth);
var nfw=GetFirstWeek(nowYear,nowMonth+1);
var ld=GetLastDays(nowYear,nowMonth);
var td=GetThisDays(nowYear,nowMonth);
var w=0;
var FrameContent;
var meLeft,meTop,winWidth,winHeight;
var monthText = new Array("01月","02月","03月","04月","05月","06月","07月","08月","09月","10月","11月","12月"); //月份文本
var weekText = new Array("sun","mon","tue","wed","thu","fri","sat"); //星期文本
//var weekText = new Array("日","一","二","三","四","五","六"); //星期文本
//显示的位置
winWidth=document.body.offsetWidth;
winHeight=document.body.offsetHeight;
if (document.getElementById(InputBoxId).getBoundingClientRect) { // For IE
meLeft=document.getElementById(InputBoxId).getBoundingClientRect().left+3;
meTop=document.getElementById(InputBoxId).getBoundingClientRect().top+document.getElementById(InputBoxId).clientHeight+3;
}
else if (document.getBoxObjectFor) { // For Mozilla
meLeft=document.getBoxObjectFor(document.getElementById(InputBoxId)).x+3+"px";
meTop=document.getBoxObjectFor(document.getElementById(InputBoxId)).y+document.getElementById(InputBoxId).clientHeight+3+"px";
}
if (((meLeft+meWidth)>winWidth)&&(meWidth<winWidth))
meLeft=winWidth-meWidth;
if ((meTop+meHeight>winHeight)&&(meHeight<winHeight))
meTop=winHeight-meHeight;
cDiv.style.display="";
cDiv.style.left=meLeft;
cDiv.style.top=meTop;
//显示日历内容
FrameContent="<div id=\"title\">";
FrameContent+="<p id=\"year\"><a class=\"btnPrev\" href=\"javascript:parent.PrevYear ('"+InputBoxId+"',"+nowYear+","+nowMonth+","+nowDay+")\" title=\"上一年\">«</a>"+nowYear+"年<a class=\"btnNext\" href=\"javascript:parent.NextYear ('"+InputBoxId+"',"+nowYear+","+nowMonth+","+nowDay+")\" title=\"下一年\">»</a> </p>";
FrameContent+="<p id=\"month\"><a class=\"btnPrev\" href=\"javascript:parent.PrevMonth ('"+InputBoxId+"',"+nowYear+","+nowMonth+","+nowDay+")\" title=\"上一个月\">«</a>"+monthText[nowMonth-1]+"<a class=\"btnNext\" href=\"javascript:parent.NextMonth ('"+InputBoxId+"',"+nowYear+","+nowMonth+","+nowDay+")\" title=\"下一个月\">»</a></p>";
FrameContent+="</div>";
FrameContent+="<div id=\"week\">";
FrameContent+="<ul>";
for (i=0; i<7; i++)
FrameContent+="<li>"+weekText[i]+"</li>";
FrameContent+="</ul>";
FrameContent+="</div>";
FrameContent+="<div id=\"day\">";
FrameContent+="<ul>";
if (fw!=0){ //第一行上月日期
for (i=(ld-fw+1);i<=ld;i++) {
if ((w%7)==0)
FrameContent+="<li class=\"otherSun\" onclick=\"parent.PrevMonth ('"+InputBoxId+"',"+nowYear+","+nowMonth+","+i+")\"><a href=\"javascript:;\">"+i+"</a></li>";
else
FrameContent+="<li class=\"otherDay\" onclick=\"parent.PrevMonth ('"+InputBoxId+"',"+nowYear+","+nowMonth+","+i+")\"><a href=\"javascript:;\">"+i+"</a></li>";
w++;
}
}
for (i=1; i<=td; i++) {
if ((w%7)==0)
FrameContent+="<li class=\"theSun\" onclick=\"parent.InputValue('"+InputBoxId+"',"+nowYear+","+nowMonth+","+i+");parent.HiddenCalendar()\"><a href=\"javascript:;\">"+i+"</a></li>";
else if ((w%7)==6)
FrameContent+="<li class=\"theSat\" onclick=\"parent.InputValue('"+InputBoxId+"',"+nowYear+","+nowMonth+","+i+");parent.HiddenCalendar()\"><a href=\"javascript:;\">"+i+"</a></li>";
else
FrameContent+="<li class=\"normal\" onclick=\"parent.InputValue('"+InputBoxId+"',"+nowYear+","+nowMonth+","+i+");parent.HiddenCalendar()\"><a href=\"javascript:;\">"+i+"</a></li>";
w++;
}
if (nfw!=0)
for (i=1; i<=(7-nfw); i++)
FrameContent+="<li class=\"otherDay\" onclick=\"parent.NextMonth('"+InputBoxId+"',"+nowYear+","+nowMonth+","+i+")\"><a href=\"javascript:;\">"+i+"</a></li>";
FrameContent+="</ul>";
FrameContent+="</div>";
FrameContent+="<div id=\"option\">";
FrameContent+="<a id=\"calendarToday\" href=\"javascript:parent.SetTodayDate('"+InputBoxId+"')\" title=\""+GetTodayDate()+"\">今天</a>";
FrameContent+="<a id=\"calendarCancel\" href=\"javascript:parent.HiddenCalendar()\">取消</a>";
FrameContent+="</div>";
cDiv.innerHTML=FrameContent;
cDiv.style.display="block";
cDiv.style.zIndex = 1107;
//鼠标经过效果以及周末颜色标志
var weekLi = document.getElementById("week").getElementsByTagName("li");
weekLi[0].className = "sun";
weekLi[6].className = "sat";
var dayLi = document.getElementById("day").getElementsByTagName("li");
for (var i=0; i<dayLi.length; i++) {
if (dayLi[i].className != "otherDay" && dayLi[i].className != "otherSun" && dayLi[i].innerText == nowDay)
dayLi[i].id = "now";
else {
dayLi[i].onmouseover = function(){
this.style.background = "#f5f5f5";
}
dayLi[i].onmouseout = function(){
this.style.background = "#fff";
}
}
}
//定义背景框架样式
cFrame.style.width = cDiv.offsetWidth;
cFrame.style.height = cDiv.offsetHeight;
cFrame.style.top = cDiv.style.top;
cFrame.style.left = cDiv.style.left;
cFrame.style.zIndex = cDiv.style.zIndex - 1;
cFrame.style.display = "block";
}
document.onclick = CloseCalendar;
/***CSS*********************************************************************************************************************/
/* CSS Document */
/* Author: Issac */
/* Date: October,2005 */
*
{
margin:0px;
padding:0px;
}
#calendar {
position: absolute;
width: 182px;
voice-family: "\"}\"";
voice-family: inherit;
width: 183px;
}
#calendar div {
font: 11px Verdana, Arial, Helvetica, sans-serif;
text-align: center;
}
#calendar a {
text-decoration: none;
}
/*日历标题(年月)*/
#calendar #title {
height: 24px;
background: url(calendar_title.gif) no-repeat left;
color: #666;
font-weight: bold;
line-height: 24px;
text-align: right;
width: 182px;
voice-family: "\"}\"";
voice-family: inherit;
width: 183px;
}
.Issac{}
#calendar #title p {
display: inline;
}
#calendar #title a {
width: 14px;
margin: 0px 2px;
background-repeat: no-repeat;
background-position: left;
color: #f60;
text-indent: -9999px;
}
#calendar #title a.btnPrev {
background-image: url(btn_prev.gif);
}
#calendar #title a.btnNext {
background-image: url(btn_next.gif);
}
/*日历星期*/
#calendar #week {
border-top: 3px solid #ccc;
border-bottom: 3px solid #ddd;
background: #eee;
height: auto;
voice-family: "\"}\"";
voice-family: inherit;
height: 100%;
}
.Issac{}
#calendar #week li {
float: left;
padding: 3px 0px;
border-right: 1px solid #eee;
border-bottom: 3px solid #999;
font: 9px Arial, Helvetica, sans-serif;
text-transform: uppercase;
width: 26px;
voice-family: "\"}\"";
voice-family: inherit;
width: 25px;
}
.Issac{}
#calendar #week .sun {
border-left: 1px solid #eee;
color: #f00;
}
#calendar #week .sat {
color: #f60;
}
/*日历日期*/
#calendar #day {
clear: both;
}
#calendar #day li {
float: left;
padding: 3px 0px;
border-right: 1px solid #ddd;
border-bottom: 1px solid #ddd;
width: 26px;
voice-family: "\"}\"";
voice-family: inherit;
width: 25px;
}
.Issac{}
#calendar #day .normal a {
color: #666;
}
#calendar #day .theSun {
border-left: 1px solid #ddd;
}
#calendar #day .theSun a{
color: #f00;
}
#calendar #day .theSat a{
color: #f60;
}
#calendar #day #now {
background: #f90;
}
#calendar #day #now a {
color: #fff;
}
#calendar #day .otherDay a {
color: #ccc;
}
#calendar #day .otherSun{
border-left: 1px solid #ddd;
}
#calendar #day .otherSun a{
color: #ccc;
}
/*日历操作(今天&取消)*/
#calendar #option {
clear: both;
height: 24px;
border-top: 2px solid #eee;
border-bottom: 3px solid #eee;
background: #f5f5f5;
line-height: 24px;
}
#calendar #option a {
margin: 0px 2px;
padding: 1px 3px 0px;
color: #333;
}
#calendar #option a:hover {
color: #f60;
border-bottom: 1px dashed #f60;
}
/********************************************************************
主题:基于CSS&LI的日历显示
作者:Smart/Issac
说明:
1.调用GetCalendar(InputBoxId);
2.问题:IE5下隐含框架zIndex属性不支持;Mozilla下尚不支持若干方法.
********************************************************************/
/*创建框架*/
document.writeln("<div id=\"calendar\"></div>");
document.writeln("<iframe id=\"calendarBox\" scrolling=\"no\" frameborder=\"0\" style=\"display:none; position:absolute;\"></iframe>");
var cDiv = document.getElementById("calendar");
var cFrame = document.getElementById("calendarBox");
/*基本参数*/
var meWidth = cDiv.clientWidth; //日历宽度
var meHeight= cDiv.clientHeight; //日历高度
var isHidden=true; //日历是否关闭
/*取得今日日期*/
function GetTodayDate() {
today=new Date();
yy=today.getYear();
mm=(today.getMonth() + 1);
if (mm<10)
mm='0'+mm;
dd=today.getDate();
if (dd<10)
dd='0'+dd;
return yy+'-'+mm+'-'+dd
}
/*输入今天日期*/
function SetTodayDate(InputBoxId) {
HiddenCalendar();
document.getElementById(InputBoxId).value=GetTodayDate();
}
/*取某年某月第一天的星期值(月份-1)*/
function GetFirstWeek(theYear,theMonth) {
return (new Date(theYear,theMonth-1,1)).getDay();
}
/*取某年某月中总天数*/
function GetThisDays(theYear,theMonth) {
return (new Date(theYear,theMonth,0)).getDate();
}
/*取某年某月上个月中总天数*/
function GetLastDays(theYear,theMonth) {
return (new Date(theYear,theMonth-1,0)).getDate();
}
/*判断是否是闰年*/
function LeapYear(theYear) {
if ((theYear%400==0) || ((theYear%4==0) && (theYear%100!=0)))
return true;
else
return false;
}
/*判断日期(YYYY-MM-DD)的日期是否正确*/
function DateIsTrue(asDate) {
var lsDate=asDate + "";
var loDate=lsDate.split("-");
if (loDate.length!=3)
return false;
var liYear=parseFloat(loDate[0]);
var liMonth=parseFloat(loDate[1]);
var liDay=parseFloat(loDate[2]);
if ((loDate[0].length>4)||(loDate[1].length>2)||(loDate[2].length>2))
return false;
if (isNaN(liYear)||isNaN(liMonth)||isNaN(liDay))
return false;
if ((liYear<1800)||(liYear>2500))
return false;
if ((liMonth>12)||(liMonth<=0))
return false;
if (GetThisDays(liYear,liMonth)<liDay)
return false;
return !isNaN(Date.UTC(liYear,liMonth,liDay));
}
/*输入框显示*/
function InputValue(InputBoxId,Year,Month,Day) {
if (Month<10)
Month='0'+Month;
if (Day<10)
Day='0'+Day;
document.getElementById(InputBoxId).value=Year+"-"+Month+"-"+Day;
}
/*上一月*/
function PrevMonth(InputBoxId,Year,Month,Day) {
Month=Month-1;
if (Month<1) {
Month=12;
Year=Year-1;
if (Year<1800)
Year=2500;
}
Day=((GetThisDays(Year,Month)<Day)?GetThisDays(Year,Month):Day);
isHidden=false;
ShowCalendar(InputBoxId,Year,Month,Day);
}
/*下一月*/
function NextMonth(InputBoxId,Year,Month,Day) {
Month=Month+1;
if (Month>12) {
Month=1;
Year=Year+1;
if (Year>2500)
Year=1800;
}
Day=((GetThisDays(Year,Month)<Day)?GetThisDays(Year,Month):Day);
isHidden=false;
ShowCalendar(InputBoxId,Year,Month,Day);
}
/*上一年*/
function PrevYear(InputBoxId,Year,Month,Day) {
Year=Year-1;
if (Year<1800)
Year=2500;
Day=((GetThisDays(Year,Month)<Day)?GetThisDays(Year,Month):Day);
isHidden=false;
ShowCalendar(InputBoxId,Year,Month,Day);
}
/*下一年*/
function NextYear(InputBoxId,Year,Month,Day) {
Year=Year+1;
if (Year>2500)
Year=1800;
Day=((GetThisDays(Year,Month)<Day)?GetThisDays(Year,Month):Day);
isHidden=false;
ShowCalendar(InputBoxId,Year,Month,Day);
}
/*根据输入框中的日期显示日历(调用方法)*/
function GetCalendar(InputBoxId) {
isHidden=false;
var boxValue=document.getElementById(InputBoxId).value;
if (DateIsTrue(boxValue)) {
loDate=boxValue.split("-");
YY=parseFloat(loDate[0]);
MM=parseFloat(loDate[1]);
DD=parseFloat(loDate[2]);
ShowCalendar(InputBoxId,YY,MM,DD);
}
else {
today=new Date();
yy=today.getYear();
mm=(today.getMonth() + 1);
dd=today.getDate();
ShowCalendar(InputBoxId,yy,mm,dd);
}
}
/*隐藏日历*/
function HiddenCalendar() {
cDiv.style.display="none";
cFrame.style.display = "none";
}
function CloseCalendar() {
if (isHidden){
cDiv.style.display="none";
cFrame.style.display = "none";
}
isHidden=true;
}
/*显示日历*/
function ShowCalendar(InputBoxId,theYear,theMonth,theDay) {
var nowYear=(theYear==null?1981:theYear);
var nowMonth=(theMonth==null?10:theMonth);
var nowDay=(theDay==null?7:theDay);
var fw=GetFirstWeek(nowYear,nowMonth);
var nfw=GetFirstWeek(nowYear,nowMonth+1);
var ld=GetLastDays(nowYear,nowMonth);
var td=GetThisDays(nowYear,nowMonth);
var w=0;
var FrameContent;
var meLeft,meTop,winWidth,winHeight;
var monthText = new Array("01月","02月","03月","04月","05月","06月","07月","08月","09月","10月","11月","12月"); //月份文本
var weekText = new Array("sun","mon","tue","wed","thu","fri","sat"); //星期文本
//var weekText = new Array("日","一","二","三","四","五","六"); //星期文本
//显示的位置
winWidth=document.body.offsetWidth;
winHeight=document.body.offsetHeight;
if (document.getElementById(InputBoxId).getBoundingClientRect) { // For IE
meLeft=document.getElementById(InputBoxId).getBoundingClientRect().left+3;
meTop=document.getElementById(InputBoxId).getBoundingClientRect().top+document.getElementById(InputBoxId).clientHeight+3;
}
else if (document.getBoxObjectFor) { // For Mozilla
meLeft=document.getBoxObjectFor(document.getElementById(InputBoxId)).x+3+"px";
meTop=document.getBoxObjectFor(document.getElementById(InputBoxId)).y+document.getElementById(InputBoxId).clientHeight+3+"px";
}
if (((meLeft+meWidth)>winWidth)&&(meWidth<winWidth))
meLeft=winWidth-meWidth;
if ((meTop+meHeight>winHeight)&&(meHeight<winHeight))
meTop=winHeight-meHeight;
cDiv.style.display="";
cDiv.style.left=meLeft;
cDiv.style.top=meTop;
//显示日历内容
FrameContent="<div id=\"title\">";
FrameContent+="<p id=\"year\"><a class=\"btnPrev\" href=\"javascript:parent.PrevYear ('"+InputBoxId+"',"+nowYear+","+nowMonth+","+nowDay+")\" title=\"上一年\">«</a>"+nowYear+"年<a class=\"btnNext\" href=\"javascript:parent.NextYear ('"+InputBoxId+"',"+nowYear+","+nowMonth+","+nowDay+")\" title=\"下一年\">»</a> </p>";
FrameContent+="<p id=\"month\"><a class=\"btnPrev\" href=\"javascript:parent.PrevMonth ('"+InputBoxId+"',"+nowYear+","+nowMonth+","+nowDay+")\" title=\"上一个月\">«</a>"+monthText[nowMonth-1]+"<a class=\"btnNext\" href=\"javascript:parent.NextMonth ('"+InputBoxId+"',"+nowYear+","+nowMonth+","+nowDay+")\" title=\"下一个月\">»</a></p>";
FrameContent+="</div>";
FrameContent+="<div id=\"week\">";
FrameContent+="<ul>";
for (i=0; i<7; i++)
FrameContent+="<li>"+weekText[i]+"</li>";
FrameContent+="</ul>";
FrameContent+="</div>";
FrameContent+="<div id=\"day\">";
FrameContent+="<ul>";
if (fw!=0){ //第一行上月日期
for (i=(ld-fw+1);i<=ld;i++) {
if ((w%7)==0)
FrameContent+="<li class=\"otherSun\" onclick=\"parent.PrevMonth ('"+InputBoxId+"',"+nowYear+","+nowMonth+","+i+")\"><a href=\"javascript:;\">"+i+"</a></li>";
else
FrameContent+="<li class=\"otherDay\" onclick=\"parent.PrevMonth ('"+InputBoxId+"',"+nowYear+","+nowMonth+","+i+")\"><a href=\"javascript:;\">"+i+"</a></li>";
w++;
}
}
for (i=1; i<=td; i++) {
if ((w%7)==0)
FrameContent+="<li class=\"theSun\" onclick=\"parent.InputValue('"+InputBoxId+"',"+nowYear+","+nowMonth+","+i+");parent.HiddenCalendar()\"><a href=\"javascript:;\">"+i+"</a></li>";
else if ((w%7)==6)
FrameContent+="<li class=\"theSat\" onclick=\"parent.InputValue('"+InputBoxId+"',"+nowYear+","+nowMonth+","+i+");parent.HiddenCalendar()\"><a href=\"javascript:;\">"+i+"</a></li>";
else
FrameContent+="<li class=\"normal\" onclick=\"parent.InputValue('"+InputBoxId+"',"+nowYear+","+nowMonth+","+i+");parent.HiddenCalendar()\"><a href=\"javascript:;\">"+i+"</a></li>";
w++;
}
if (nfw!=0)
for (i=1; i<=(7-nfw); i++)
FrameContent+="<li class=\"otherDay\" onclick=\"parent.NextMonth('"+InputBoxId+"',"+nowYear+","+nowMonth+","+i+")\"><a href=\"javascript:;\">"+i+"</a></li>";
FrameContent+="</ul>";
FrameContent+="</div>";
FrameContent+="<div id=\"option\">";
FrameContent+="<a id=\"calendarToday\" href=\"javascript:parent.SetTodayDate('"+InputBoxId+"')\" title=\""+GetTodayDate()+"\">今天</a>";
FrameContent+="<a id=\"calendarCancel\" href=\"javascript:parent.HiddenCalendar()\">取消</a>";
FrameContent+="</div>";
cDiv.innerHTML=FrameContent;
cDiv.style.display="block";
cDiv.style.zIndex = 1107;
//鼠标经过效果以及周末颜色标志
var weekLi = document.getElementById("week").getElementsByTagName("li");
weekLi[0].className = "sun";
weekLi[6].className = "sat";
var dayLi = document.getElementById("day").getElementsByTagName("li");
for (var i=0; i<dayLi.length; i++) {
if (dayLi[i].className != "otherDay" && dayLi[i].className != "otherSun" && dayLi[i].innerText == nowDay)
dayLi[i].id = "now";
else {
dayLi[i].onmouseover = function(){
this.style.background = "#f5f5f5";
}
dayLi[i].onmouseout = function(){
this.style.background = "#fff";
}
}
}
//定义背景框架样式
cFrame.style.width = cDiv.offsetWidth;
cFrame.style.height = cDiv.offsetHeight;
cFrame.style.top = cDiv.style.top;
cFrame.style.left = cDiv.style.left;
cFrame.style.zIndex = cDiv.style.zIndex - 1;
cFrame.style.display = "block";
}
document.onclick = CloseCalendar;
/***CSS*********************************************************************************************************************/
/* CSS Document */
/* Author: Issac */
/* Date: October,2005 */
*
{
margin:0px;
padding:0px;
}
#calendar {
position: absolute;
width: 182px;
voice-family: "\"}\"";
voice-family: inherit;
width: 183px;
}
#calendar div {
font: 11px Verdana, Arial, Helvetica, sans-serif;
text-align: center;
}
#calendar a {
text-decoration: none;
}
/*日历标题(年月)*/
#calendar #title {
height: 24px;
background: url(calendar_title.gif) no-repeat left;
color: #666;
font-weight: bold;
line-height: 24px;
text-align: right;
width: 182px;
voice-family: "\"}\"";
voice-family: inherit;
width: 183px;
}
.Issac{}
#calendar #title p {
display: inline;
}
#calendar #title a {
width: 14px;
margin: 0px 2px;
background-repeat: no-repeat;
background-position: left;
color: #f60;
text-indent: -9999px;
}
#calendar #title a.btnPrev {
background-image: url(btn_prev.gif);
}
#calendar #title a.btnNext {
background-image: url(btn_next.gif);
}
/*日历星期*/
#calendar #week {
border-top: 3px solid #ccc;
border-bottom: 3px solid #ddd;
background: #eee;
height: auto;
voice-family: "\"}\"";
voice-family: inherit;
height: 100%;
}
.Issac{}
#calendar #week li {
float: left;
padding: 3px 0px;
border-right: 1px solid #eee;
border-bottom: 3px solid #999;
font: 9px Arial, Helvetica, sans-serif;
text-transform: uppercase;
width: 26px;
voice-family: "\"}\"";
voice-family: inherit;
width: 25px;
}
.Issac{}
#calendar #week .sun {
border-left: 1px solid #eee;
color: #f00;
}
#calendar #week .sat {
color: #f60;
}
/*日历日期*/
#calendar #day {
clear: both;
}
#calendar #day li {
float: left;
padding: 3px 0px;
border-right: 1px solid #ddd;
border-bottom: 1px solid #ddd;
width: 26px;
voice-family: "\"}\"";
voice-family: inherit;
width: 25px;
}
.Issac{}
#calendar #day .normal a {
color: #666;
}
#calendar #day .theSun {
border-left: 1px solid #ddd;
}
#calendar #day .theSun a{
color: #f00;
}
#calendar #day .theSat a{
color: #f60;
}
#calendar #day #now {
background: #f90;
}
#calendar #day #now a {
color: #fff;
}
#calendar #day .otherDay a {
color: #ccc;
}
#calendar #day .otherSun{
border-left: 1px solid #ddd;
}
#calendar #day .otherSun a{
color: #ccc;
}
/*日历操作(今天&取消)*/
#calendar #option {
clear: both;
height: 24px;
border-top: 2px solid #eee;
border-bottom: 3px solid #eee;
background: #f5f5f5;
line-height: 24px;
}
#calendar #option a {
margin: 0px 2px;
padding: 1px 3px 0px;
color: #333;
}
#calendar #option a:hover {
color: #f60;
border-bottom: 1px dashed #f60;
}
发表评论
-
angular分析
2014-07-08 13:49 1067angular分析 -
键盘KeyCode值列表
2012-08-28 18:13 1106keycode 0 = keycode 1 = k ... -
JavaScript中的delete操作符
2012-04-20 14:17 1500主要从以下几个方面说 ... -
javascript性能优化之一
2012-04-04 21:01 0该篇文章转自 http://blog.sina.com.cn ... -
DOM节点中属性nodeName、nodeType和nodeValue的区别
2012-03-20 17:31 3744(一)nodeName 属性含有某个节点的名称。 元素节 ... -
javascript正则表达式总结
2012-03-16 13:53 1499正则表达式中特殊字符的含义 1、^ ^匹配输入字符串 ... -
javascript常用知识点总结(不断完善)
2011-07-04 17:15 1174一、函数中调用函数的实现 /** * 以下为 ... -
js对象的克隆
2011-06-14 15:02 2098由于js是采用引用传值的,故修改任何一个对象,其关 ... -
javascript中静态方法、实例方法、内部方法和原型的一点见解
2011-06-11 15:54 85951、静态方法的定义 var BaseClass = f ... -
javascript contains和compareDocumentPosition 方法来确定是否HTML节点
2011-03-30 17:41 14941、DOMElement.contains(DOMNode) ... -
事件mouseenter和事件mouseleave
2011-03-14 14:52 1821为了鼠标操作起来方便,IE实现了mouseenter 和m ... -
浏览器事件机制与自定义事件的实现
2011-03-14 14:03 4050一、 0 级 DOM 上的事件 ... -
table列表中结合ctrl,shift实现多行的选择
2009-06-12 15:16 4424以下是简单的实现了tabl ... -
JavaScript中Array(数组)的属性和方法
2009-06-03 17:13 1407数组有四种定义的方式 ... -
表格自动换行
2008-12-02 11:06 3050有时表格中显示的内容不会根据长度的加长而自动换行,显示的效果很 ... -
让表格有滚动条的实现
2008-12-02 10:23 5631主要是用div样式来控制 例如 <html> ... -
利用javascript验证输入框中的值是否为日期格式
2008-09-02 15:45 127911、判断是否为年月日时间格式 <script> ... -
web一些值得珍藏的脚本代码
2008-08-01 09:50 13201. oncontextmenu="window.e ... -
div垂直和水平居中
2008-06-29 16:34 1743<div id="div_1" st ... -
JS获取系统当前日期和时间
2008-06-29 16:31 6752<!DOCTYPE HTML PUBLIC " ...
相关推荐
总的来说,JavaScript创建的日历控件可以极大地增强用户体验,而My97DatePicker等库则提供了便捷的方式来实现这一功能,减少了开发时间和复杂性。通过深入理解和实践这些技术,你可以创建出符合需求的自定义日历组件...
创建日历控件首先需要在HTML中添加一个触发显示日历的按钮或者输入框,然后用JavaScript动态生成日历的HTML结构并插入到页面中。 2. **事件处理**:在JavaScript中,我们可以监听用户的点击、鼠标移动等事件,并...
### 使用CSS和JavaScript创建日历控件的知识点详解 #### 一、项目概述 本项目旨在通过CSS和JavaScript实现一个可交互的日历控件。该控件不仅具有良好的视觉效果,还能让用户方便地选择日期,并在选中日期时提供反馈...
3. **JavaScript初始化**:在页面加载时,使用JavaScript初始化日历控件,这可能包括设置初始日期、创建日历UI元素以及添加事件监听器。 4. **事件处理**:当用户点击年份、月份选择器或日期单元格时,我们需要监听...
1. **性能优化**:在创建日历控件时,减少DOM操作是关键。利用虚拟DOM或仅在必要时更新DOM可以显著提升性能。此外,使用事件委托来处理用户交互,而非为每个元素绑定事件,可以降低内存消耗。 2. **响应式设计**:...
首先,我们要明白什么是JavaScript(JS)日历控件。它是一种基于JavaScript编程语言的用户界面组件,允许用户在网页上以图形化的方式选择日期。这种控件通常以弹出窗口的形式出现,显示一个月份的日历,用户可以通过...
- **自定义实现**:开发者可以利用JavaScript原生API创建日历,如DOM操作、事件处理等,从无到有构建整个日历界面和交互逻辑。 - **第三方库**:有很多成熟的JavaScript日历库,如`protocalendar-js-1.1.0`,它们...
总的来说,JavaScript日历控件是网页交互中不可或缺的一部分,它的实现涉及前端多个技术层面,从基础的HTML/CSS/JS到复杂的库使用和性能优化。理解其工作原理并灵活运用,能帮助开发者创建出更高效、更易用的网页...
创建一个js日历控件,主要涉及以下几个知识点: 1. **DOM操作**:JavaScript通过Document Object Model(DOM)与HTML页面进行交互。你需要理解如何使用DOM API来创建、查找、修改和删除HTML元素。例如,创建一个...
开发者可能使用了`<input type="text">`来创建一个日期输入字段,并通过JavaScript与`js.js`文件进行交互,当用户点击这个字段时,日历控件会弹出。 `js.js` 文件则是整个日历控件的核心,它包含了实现日历功能的...
本文将围绕“JS精美日历控件”这一主题,详细介绍如何利用JavaScript实现一个功能丰富的日历插件,以My97DatePicker为例进行深入探讨。 My97DatePicker是一款广泛使用的JavaScript日历插件,它具有良好的兼容性,...
JS日历控件是利用JavaScript编程语言实现的此类功能,它能够提供直观、友好的用户体验。本文将深入探讨JS日历控件的原理、实现方式以及相关知识点。 一、日历控件的基本概念 日历控件是一种用户界面组件,它以日历...
JavaScript日历控件是网页开发中常用的一种交互元素,它能帮助用户方便地选择日期,常见于表单输入、事件安排或时间相关的功能。在给定的资源中,包含了六种不同样式的JavaScript日历,这些日历可能具有不同的设计...
4. 兼容性好:随着浏览器对JavaScript支持的增强,大多数现代浏览器都能良好运行JS日历控件。 5. 可扩展性:可以结合其他库如jQuery、React等,进一步增强功能,如添加时间选择、多选日期等。 三、应用场景 1. 表单...
创建一个JavaScript日历控件涉及到以下几个关键知识点: 1. **DOM操作**:日历控件需要动态地在网页上生成元素,这需要利用JavaScript对文档对象模型(DOM)进行操作。例如,可以使用`document.createElement()`...
综上所述,“js日历控件集合”涵盖了各种JavaScript实现的日历组件,每种都有其独特特性和应用场景。根据项目需求,选择合适且易于维护的控件至关重要。在实际开发中,应充分理解这些控件的工作原理和配置选项,以便...
从JavaScript实现到多样化功能,从用户体验到跨平台兼容性,理解并掌握日历控件的开发可以提升开发者在创建高效、用户友好的应用程序上的能力。通过学习和分析提供的文件,我们可以深入探究这些方面的具体实现和技巧...
- JavaScript文件(如`calendar.js`):包含日历控件的逻辑代码。 - HTML文件(如`index.html`):展示日历控件的示例页面。 - 可能还有其他资源文件,如图片或字体。 为了使日历控件更强大,我们还可以考虑增加...
- JSP中,你可以使用Java的开源库,如`JQuery UI`的日期插件,或者`CalendarTag`库来创建日历控件。`JQuery UI`提供了一款美观易用的日历插件,只需引入对应的JavaScript和CSS文件,然后通过JavaScript代码调用来...
在IT领域,日历控件是一种常见的用户界面元素,它允许用户方便地选择日期或进行日期相关的操作。在“日历控件12”中,我们可能会遇到一系列关于如何集成、自定义以及优化这种控件的知识点。下面将详细介绍这些内容。...