DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁製作工具 >> Dreamweaver教程 >> Dreamweaver相關 >> 用DW在網頁中顯示可拖動月歷
用DW在網頁中顯示可拖動月歷
編輯:Dreamweaver相關     

使用本文提供的JavaScript腳本,配合Dreamweaver的層和行為的運用,可以在頁面中顯示可拖動的精美月歷。

具體制作步驟如下:

1、啟動Dreamweaver MX,新建一個HTML文檔,切換到代碼視圖,編寫JavaScript腳本。

(1)在HTML文檔的< head>...< /head>插入下面的JavaScript腳本:

< SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
  //定義月歷函數
  function calendar() {
  var today = new Date(); //創建日期對象
  year = today.getYear(); //讀取年份
  thisDay = today.getDate(); //讀取當前日

//創建每月天數數組
  var monthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
  //如果是閏年,2月份的天數為29天
  if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monthDays[1] = 29;
  daysOfCurrentMonth = monthDays[today.getMonth()]; //從每月天數數組中讀取當月的天數
  firstDay = today;//復制日期對象
  firstDay.setDate(1); //設置日期對象firstDay的日為1號
  startDay = firstDay.getDay(); //確定當月第一天是星期幾

//定義周日和月份中文名數組
  var dayNames = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
  var monthNames = new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");
  //創建日期對象
  var newDate = new Date();

//創建表格
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'>");

//顯示當前日期和周日
  document.writeln("< FONT STYLE='font-size:9pt;Color:#FF0000'>" + newDate.getYear() + "年" + monthNames[newDate.getMonth()] + " " + newDate.getDate() + "日 " + dayNames[newDate.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=

123下一頁
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved