大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 网页设计 -> HTML/CSS -> HTML组件(HTML COMPONENTS)之六

HTML组件(HTML COMPONENTS)之六

时间: 2021-07-31 作者:daque

====日历网页面===

<head> <title>calendar example</title> <?import namespace="mycal" implementation="calendar.htc"/> </head> <body> <p>click a day in the calendar to add or modify your schedule.</p> <mycal:calendar></mycal:calendar> </body> </html>

 ===calendar htc===

<head> <?import namespace="anyday" implementation="day.htc"/> <?import namespace="today" implementation="today.htc"/> <public:component tagname="calendar"> <attach event="oncontentready" onevent="fninit()"/> </public:component> <script language="javascript"> <!-- function fninit() { defaults.viewlink = document; } // --> </script> <style> td { background-color:tan; width:50; height:50; } </style> </head> <body> <script language="javascript"> <!-- // copyright 1997 -- tomer shiran setcal(); function leapyear(year) { if (year % 4 == 0) {// basic rule return true; // is leap year } /* else */ // else not needed when statement is "return" return false; // is not leap year } function getdays(month, year) { // create array to hold number of days in each month var ar = new array(12); ar[0] = 31; // january ar[1] = (leapyear(year)) ? 29 : 28; // february ar[2] = 31; // march ar[3] = 30; // april ar[4] = 31; // may ar[5] = 30; // june ar[6] = 31; // july ar[7] = 31; // august ar[8] = 30; // september ar[9] = 31; // october ar[10] = 30; // november ar[11] = 31; // december // return number of days in the specified month (parameter) return ar[month]; } function getmonthname(month) { // create array to hold name of each month var ar = new array(12); ar[0] = "january"; ar[1] = "february"; ar[2] = "march"; ar[3] = "april"; ar[4] = "may"; ar[5] = "june"; ar[6] = "july"; ar[7] = "august"; ar[8] = "september"; ar[9] = "october"; ar[10] = "november"; ar[11] = "december"; // return name of specified month (parameter) return ar[month]; } function setcal() { // standard time attributes var now = new date(); var year = now.getfullyear(); var month = now.getmonth(); var monthname = getmonthname(month); var date = now.getdate(); now = null; // create instance of first day of month, and extract the day on which it occurs var firstdayinstance = new date(year, month, 1); var firstday = firstdayinstance.getday(); firstdayinstance = null; // number of days in current month var days = getdays(month, year); // call function to draw calendar drawcal(firstday + 1, days, date, monthname, year); } function drawcal(firstday, lastdate, date, monthname, year) { // constant table settings //var headerheight = 50 // height of the table's header cell var border = 2; // 3d height of table's border var cellspacing = 4; // width of table's border var headercolor = "midnightblue"; // color of table's header var headersize = "+3"; // size of tables header font var colwidth = 60; // width of columns in table var daycellheight = 25; // height of cells containing days of the week var daycolor = "darkblue"; // color of font representing week days var cellheight = 40; // height of cells representing dates in the calendar var todaycolor = "red"; // color specifying today's date in the calendar var timecolor = "purple"; // color of font representing current time // create basic table structure var text = ""; // initialize accumulative variable to empty string text += '<table border=' + border + ' cellspacing=' + cellspacing + '>'; // table settings text += '<th colspan=7 height=' + 10 + '>'; // create table header cell text += '<font color="' + headercolor + '" size=' + headersize + '>'; // set font for table header text += monthname + ' ' + year; text += '</font>'; // close table header's font settings text += '</th>'; // close header cell // variables to hold constant settings var opencol = '<td width=' + colwidth + ' height=' + daycellheight + '>'; opencol += '<font color="' + daycolor + '">'; var closecol = '</font></td>'; // create array of abbreviated day names var weekday = new array(7); weekday[0] = "sun"; weekday[1] = "mon"; weekday[2] = "tues"; weekday[3] = "wed"; weekday[4] = "thu"; weekday[5] = "fri"; weekday[6] = "sat"; // create first row of table to set column width and specify week day text += '<tr align="center" valign="center">'; for (var daynum = 0; daynum < 7; ++daynum) { text += opencol + weekday[daynum] + closecol; } text += '</tr>'; // declaration and initialization of two variables to help with tables var dayofmonth = 1; var curcell = 1; for (var row = 1; row <= math.ceil((lastdate + firstday - 1) / 7); ++row) { text += '<tr align="right" valign="top">'; for (var col = 1; col <= 7; ++col) { if ((curcell < firstday) || (dayofmonth > lastdate)) { text += '<td></td>'; curcell++ } else { if (dayofmonth == date) { // current cell represents today's date text += '<td><today:day value=' + dayofmonth + '></today:day></td>'; } else { text += '<td><anyday:day value=' + dayofmonth + '></anyday:day></td>'; } dayofmonth++; } } text += '</tr>'; } // close all basic table tags text += '</table>'; text += '</center>'; // print accumulative html string document.write(text); } // --> </script> </body> </html>

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.