⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 popupcal.js

📁 搭建智元软件公文传输系统运行环境(搭建智元软件公文传输系统运行环境转载)
💻 JS
📖 第 1 页 / 共 2 页
字号:
//用JavaScript在web下弹出日历选择框

var popCalDstFld;
var popCalWin;

function popupCal()

{
            var tmpDate = new Date();
            var tmpString = "";
            var tmpNum = 0;
            var popCalDateVal; 

            //Initialize the window to an empty object.
            popCalWin = new Object();

            //Check for the right number of arguments
            if (arguments.length < 2){
                        
                        alert("popupCal(): Wrong number of arguments.");
                        return void(0);

            }

            //Get the command line arguments -- label is optional

            var dstWindowName = popupCal.arguments[0];
            popCalDstFld = popupCal.arguments[1];


            if(arguments.length > 2)

                        var fieldLabel = popupCal.arguments[2];

            else

                        var fieldLabel = "请点击要指定的日期:";


            tmpString = new String(popCalDstFld.value).replace(/[\.-]/g,"/");

            //If tmpString is empty (meaning that the field is empty) use todays date as the starting point

            if(tmpString == ""){

                        popCalDateVal = new Date()

            }

            else{

                        //Make sure the century is included, if it isn't, add this century to the value that was
                        //in the field

                        tmpNum = tmpString.indexOf( "/" );
                        if ( tmpNum <= 2 && tmpNum>0){
                                    tmpString = parseInt(tmpDate.getFullYear()/100)+ ((tmpNum=1)?"0":"") +tmpString.substr(0,tmpNum) + tmpString.substring(tmpNum);
                                    popCalDateVal = new Date(tmpString);
                        } else {
                                    //If we got to this point, it means the field that was passed in had a 4 digit number after
                                    //the last slash.  Try to convert it to a date

                                    popCalDateVal = new Date(tmpString.toString());
                        };

                        popCalDateVal = new Date(tmpString.toString()); //add by lh
            };

           
            //Make sure the date is a valid date.  Set it to today if it is invalid

            if( isNaN(popCalDateVal) ){
                        popCalDateVal = new Date();}

                                    

            //Set the base date to midnight of the first day of the specified month, this makes things easier?

 

            //Call the routine to draw the initial calendar

            var dateString = String(popCalDateVal.getFullYear()) + "/" + String(popCalDateVal.getMonth()+1) + "/" + String(popCalDateVal.getDate());

            reloadCalPopup(dateString, dstWindowName, fieldLabel);

            return void(0);

}

 

function closeCalPopup(){

            //Can't tell the child window to close itself, the parent window has to tell it to close.
            popCalWin.close();
            return void(0);
}

 

function reloadCalPopup(){

            //Set the window's features here

            var windowFeatures = "height=300,width=235,resizable=no";

            var tmpDate = new Date( reloadCalPopup.arguments[0] );
          

            if ( isNaN(tmpDate) ) tmpDate = new Date();
            

            tmpDate.setDate(1);

            

            //Get the calendar data
            var popCalData = calPopupSetData(tmpDate, reloadCalPopup.arguments[2],reloadCalPopup.arguments[1]);

            //Check to see if the window has been initialized, create it if it hasn't been
            if( popCalWin.toString() == "[object Object]" ){
                        popCalWin = window.open("",reloadCalPopup.arguments[1],windowFeatures);
            } else {
                        //Remember the existing window's position

                        var xPos = popCalWin.screenX;
                        var yPos = popCalWin.screenY;
                        popCalWin.document.open();
            }

            

            popCalWin.document.write(popCalData);
            popCalWin.document.close();

            return void(0);
}

 

function calPopupSetData(firstDay,fieldLabel,dstWindowName){

            var popCalData = "";
   		  var lastDate = 0;
            var fnt = new Array( "<FONT SIZE=\"1\">", "<FONT SIZE=\"1\">", "<FONT SIZE=\"1\" COLOR=\"#CC2222\">", "<FONT SIZE=\"2\" COLOR=\"#FF00FF\">");
            var dtToday = new Date();
            var thisMonth = firstDay.getMonth();
            var thisYear = firstDay.getFullYear();
            var nPrevMonth = (thisMonth == 0 ) ? 11 : (thisMonth - 1);
            var nNextMonth = (thisMonth == 11 ) ? 0 : (thisMonth + 1);
            var nPrevMonthYear = (nPrevMonth == 11) ? (thisYear - 1): thisYear;
            var nNextMonthYear = (nNextMonth == 0) ? (thisYear + 1): thisYear;
          

            var sToday = String(dtToday.getFullYear() +"/" + (dtToday.getMonth()+1) + "/01");
            var sPrevMonth = String(nPrevMonthYear +"/" + (nPrevMonth+1) + "/01");
            var sNextMonth = String(nNextMonthYear +"/" + (nNextMonth+1) + "/01");
            var sPrevYear1 = String((thisYear - 1) +"/" + (thisMonth+1) + "/01");
            var sNextYear1 = String((thisYear + 1) +"/" + (thisMonth+1) + "/01");
            var sPrevYear2 = String((thisYear - 2) +"/" + (thisMonth+1) + "/01");
            var sNextYear2 = String((thisYear + 2) +"/" + (thisMonth+1) + "/01");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -