The Javascript scenario that use article offers, of the layer that cooperates Dreamweaver and behavior apply, can show in the page can pull the elegant monthly calendar that change.
The concrete move that make is as follows:
1, the Dreamweaver MX that start, build documentation of a HTML, switch arrives code view, write Javascript script.
(1) is in of HTML documentation<Head> . . . </ Head> inserts the Javascript script below:
<SCRIPT LANGUAGE= "javascript" TYPE= "text/javascript" >
/ / definition menology function
Function Calendar() {
Var Today = New Date(); // establishs date target
Year = Today.getYear(); // is read take a particular year
ThisDay = Today.getDate(); // is read take current day
/ / establish group of count of every months of day
Var MonthDays = New Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
/ / if be bissextile, the day number Feburary is 29 days
If (((year % 4==0) &&(Year % 100! = 0)) | | (Year % 400==0)) MonthDays[1] = 29;
DaysOfCurrentMonth = MonthDays[today.getMonth()]; // is counted from every months of day read in array take the day that month to count
Object of duplicate date of FirstDay = Today;//
FirstDay.setDate(1); // installs the day of date object FirstDay to be 1
StartDay = FirstDay.getDay(); // is affirmatory that month the first day is a week a few
/ / definition weekday and group of month Chinese concrete number
Sunday ” of Var DayNames = New Array(” , “On Monday ” , “Tuesday ” , “On Wednesday ” , “On Thursday ” , “On Friday ” , “On Saturday ” );
” of month of Var MonthNames = New Array(”1, “In Feburary ” , “In March ” , “In April ” , “In May ” , “In June ” , “In July ” , “In August ” , “In September ” , “In October ” , “In November ” , “In December ” );
/ / establish date target
Var NewDate = New Date();
/ / found form
Document.write(”<TABLE BORDER=’0′ CELLSPACING=’0′ CELLPADDING=’2′ ALIGN=’CENTER’ BGCOLOR=’#0080FF’>" )
Document.write(”<TR><TD><Table Border=’0′ Cellspacing=’1′ Cellpadding=’2′ Bgcolor=’#88FF99′>" );
Document.write(”<TR><Th Colspan=’7′ Bgcolor=’#C8E3FF’>" );
/ / show current date and weekday
Document.writeln(”<FONT STYLE=’font-size:9Pt;Color:#FF0000′>" NewDate.getYear() " year " DayNames[newDate.getDay()] of day of " MonthNames[newDate.getMonth()] " " NewDate.getDate() " "</ FONT>" );
/ / indication menology expresses a head
Document.writeln(”</ TH></ TR><TR><TH BGCOLOR=’#0080FF’><FONT STYLE=’font-size:9Pt;Color:WHite’> day</ FONT></ TH>" );
Document.writeln(”<Th Bgcolor=’#0080FF’><FONT STYLE=’font-size:9Pt;Color:WHite’> one</ FONT></ TH>" );
Document.writeln(”<TH BGCOLOR=’#0080FF’><FONT STYLE=’font-size:9Pt;Color:WHite’> 2</ FONT></ TH>" );
Document.writeln(”<TH BGCOLOR=’#0080FF’><FONT STYLE=’font-size:9Pt;Color:WHite’> 3</ FONT></ TH>" );
Document.writeln(”<TH BGCOLOR=’#0080FF’><FONT STYLE=’font-size:9Pt;Color:WHite’> 4</ FONT></ TH>" );
Document.writeln(”<TH BGCOLOR=’#0080FF’><FONT STYLE=’font-size:9Pt;Color:WHite’> 5</ FONT></ TH>" );
Document.writeln(”<TH BGCOLOR=’#0080FF’><FONT STYLE=’font-size:9Pt;Color:WHite’> 6</ FONT></ TH>" );
Document.writeln(”</ TR><TR>" );
/ / show every months of ” empty day in front “
Column = 0;
Document.writeln(”\n of of of For (i=0; I<TD><FONT STYLE=’font-size:9Pt’></ FONT></ TD>" );
Column ;
}
/ / if be current day is highlighted,show (gules) , show normally otherwise (black)
For (i=1; I<=daysOfCurrentMonth; I ) {
If (i==ThisDay) {
Document.writeln(”</ TD><TD ALIGN=’CENTER’><FONT STYLE=’font-size:9Pt;Color:#Ff0000′><B>" )
}
Else {
Document.writeln(”</ TD><TD BGCOLOR=’#88FF99′ ALIGN=’CENTER’><FONT STYLE=’font-size:9Pt;font-family:ARial;font-weight:bOld;Color:#000000′>" );
}
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=’time’ OnSubmit=’0′><FONT STYLE=’font-size:9Pt;Color:#Ffffff’>" )
/ / show present time
Document.writeln(” present time: ≪ INPUT TYPE=’Text’ NAME=’textbox’ ALIGN=’TOP’></ FONT></ TD></ TR></ TABLE>" )
Document.writeln(”</ TD></ TR></ TABLE></ FORM>" );
}
</ SCRIPT>
<SCRIPT LANGUAGE= "javascript" >
/ / initialization controls variable
Var TimerID = Null;
Var TimerRunning = False;
/ / definition time displays function
Function Stoptime (){
If(timerRunning)
ClearTimeout(timerID);
TimerRunning = False;}
/ / the definition displays time function
Function Showtime () {
Var NewDate = New Date();
Var Hours = NewDate.getHours();
Var Minutes = NewDate.getMinutes();
Var Seconds = NewDate.getSeconds()
Var TimeValue = " " ((hours >12) ? Hours -12:hOurs)
TimeValue = ((minutes<10) ? “: 0″: “:” ) Minutes
TimeValue = ((seconds<10) ? “: 0″: “:” ) Seconds
TimeValue = (hours >= 12) ? “Afternoon ” : “In the morning “
Document.time.textbox.value = TimeValue;
TimerID = SetTimeout(”showtime()” , 1000);// sets overtime, make time trends shows
TimerRunning = True;}
/ / show present time
Function Starttime () {
Stoptime();
Showtime();}
</ SCRIPT>
(2) is in HTML documentation text<Body> . . . </ Javascript script is inserted in Body> , give<Body> mark adds a few attribute:
<BODY OnLoad= "starttime()" TEXT= "#000000" TOPMARGIN= "0" >
<Script Language= "javascript" Type= "text/javascript" >
Calendar(); // shows monthly calendar
</ Script>
</ BODY>
2, switch arrives design view, one is inserted in the page, and the Javascript script icon in representing HTML documentation text (if this icon did not show, choose menu of View>Visual Aids>Invisible Elements to command please) in pulling a layer, following plan institute are shown.
Bookmark:Digg Del.icio.us Reddit
