找回密码
 注册
搜索
免费空间 免费域名 免费AI 老牌主机商首月仅1美分!27美元/年!Spaceship优惠码 Namecheap优惠码阿里云2核2G3M新老续费同享99元/年!
查看: 267|回复: 10

怎么让这个模块在网页中左对齐(或者自动对位)

[复制链接]
发表于 2009-9-9 20:13:53 | 显示全部楼层 |阅读模式
  1. <html>

  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  4. <title>网页特效---一个很漂亮实用的日历</title>
  5. <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
  6. //创建一个数组,用于存放每个月的天数
  7. function montharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11)
  8. {
  9. this[0] = m0;
  10. this[1] = m1;
  11. this[2] = m2;
  12. this[3] = m3;
  13. this[4] = m4;
  14. this[5] = m5;
  15. this[6] = m6;
  16. this[7] = m7;
  17. this[8] = m8;
  18. this[9] = m9;
  19. this[10] = m10;
  20. this[11] = m11;
  21. }
  22. //实现月历
  23. function calendar() {
  24. var monthNames = "JanFebMarAprMayJunJulAugSepOctNovDec";
  25. var today = new Date();
  26. var thisDay;
  27. var monthDays = new montharr(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
  28. year = today.getYear() +1900;
  29. thisDay = today.getDate();
  30. if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monthDays[1] = 29;
  31. nDays = monthDays[today.getMonth()];
  32. firstDay = today;
  33. firstDay.setDate(1);
  34. testMe = firstDay.getDate();
  35. if (testMe == 2) firstDay.setDate(0);
  36. startDay = firstDay.getDay();
  37. document.write("<div id='rili' style='position:absolute;width:140px;left:300px;top:100px;'>")
  38. document.write("<TABLE width='217' BORDER='0' CELLSPACING='0' CELLPADDING='2' BGCOLOR='#0080FF'>")
  39. document.write("<TR><TD><table border='0' cellspacing='1' cellpadding='2' bgcolor='Silver'>");
  40. document.write("<TR><th colspan='7' bgcolor='#C8E3FF'>");
  41. var dayNames = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
  42. var monthNames = new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");
  43. var now = new Date();
  44. document.writeln("<FONT STYLE='font-size:9pt;Color:#330099'>" + "公元 " + now.getYear() + "年" + monthNames[now.getMonth()] + " " + now.getDate() + "日 " + dayNames[now.getDay()] + "</FONT>");
  45. document.writeln("</TH></TR><TR><TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>日</FONT></TH>");
  46. document.writeln("<th bgcolor='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>一</FONT></TH>");
  47. document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>二</FONT></TH>");
  48. document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>三</FONT></TH>");
  49. document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>四</FONT></TH>");
  50. document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>五</FONT></TH>");
  51. document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>六</FONT></TH>");
  52. document.writeln("</TR><TR>");
  53. column = 0;
  54. for (i=0; i<startDay; i++) {
  55. document.writeln("\n<TD><FONT STYLE='font-size:9pt'> </FONT></TD>");
  56. column++;
  57. }

  58. for (i=1; i<=nDays; i++) {
  59. if (i == thisDay) {
  60. document.writeln("</TD><TD ALIGN='CENTER' BGCOLOR='#FF8040'><FONT STYLE='font-size:9pt;Color:#ffffff'><B>")
  61. }
  62. else {
  63. document.writeln("</TD><TD BGCOLOR='#FFFFFF' ALIGN='CENTER'><FONT STYLE='font-size:9pt;font-family:Arial;font-weight:bold;Color:#330066'>");
  64. }
  65. document.writeln(i);
  66. if (i == thisDay) document.writeln("</FONT></TD>")
  67. column++;
  68. if (column == 7) {
  69. document.writeln("<TR>");
  70. column = 0;
  71. }
  72. }
  73. document.writeln("<TR><TD COLSPAN='7' ALIGN='CENTER' VALIGN='TOP' BGCOLOR='#0080FF'>")
  74. document.writeln("<FORM NAME='clock' onSubmit='0'><FONT STYLE='font-size:9pt;Color:#ffffff'>")
  75. document.writeln("现在时间:<INPUT TYPE='Text' NAME='face' ALIGN='TOP'></FONT></FORM></TD></TR></TABLE>")
  76. document.writeln("</TD></TR></TABLE></div>");
  77. }
  78. </SCRIPT>
  79. <SCRIPT LANGUAGE="JavaScript">
  80. var timerID = null;
  81. var timerRunning = false;

  82. function stopclock (){
  83. if(timerRunning)
  84. clearTimeout(timerID);
  85. timerRunning = false;}

  86. //显示当前时间
  87. function showtime () {
  88. var now = new Date();
  89. var hours = now.getHours();
  90. var minutes = now.getMinutes();
  91. var seconds = now.getSeconds()
  92. var timeValue = " " + ((hours >12) ? hours -12 :hours)
  93. timeValue += ((minutes < 10) ? ":0" : ":") + minutes
  94. timeValue += ((seconds < 10) ? ":0" : ":") + seconds
  95. timeValue += (hours >= 12) ? " 下午 " : " 上午 "
  96. document.clock.face.value = timeValue;
  97. timerID = setTimeout("showtime()",1000);//设置超时,使时间动态显示
  98. timerRunning = true;}

  99. function startclock () {
  100. stopclock();
  101. showtime();}
  102. </SCRIPT>
  103. </head>

  104. <body onLoad="startclock(); timerONE=window.setTimeout">

  105. <script language="JavaScript" type="text/javascript">
  106. <!--
  107. calendar();
  108. //-->

  109. </script>

  110. </body>

  111. </html>
复制代码
发表于 2009-9-9 20:15:35 | 显示全部楼层
向后转...走错门了。
发表于 2009-9-9 20:16:26 | 显示全部楼层
同楼上
 楼主| 发表于 2009-9-9 20:18:49 | 显示全部楼层
发表于 2009-9-9 20:20:40 | 显示全部楼层
差了句起步走...


其实我不知道
发表于 2009-9-9 20:34:25 | 显示全部楼层
- - 设置坐标。
发表于 2009-9-9 20:36:01 | 显示全部楼层
不懂,帮顶
发表于 2009-9-10 10:56:01 | 显示全部楼层
本帖最后由 tincco 于 2009-9-10 11:00 编辑
  1. <html>



  2. <head>

  3. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">

  4. <title>网页特效---一个很漂亮实用的日历</title>
  5. <style type="text/css">
  6. body {text-align:left;}
  7. </style>

  8. <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

  9. //创建一个数组,用于存放每个月的天数

  10. function montharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11)

  11. {

  12. this[0] = m0;

  13. this[1] = m1;

  14. this[2] = m2;

  15. this[3] = m3;

  16. this[4] = m4;

  17. this[5] = m5;

  18. this[6] = m6;

  19. this[7] = m7;

  20. this[8] = m8;

  21. this[9] = m9;

  22. this[10] = m10;

  23. this[11] = m11;

  24. }

  25. //实现月历

  26. function calendar() {

  27. var monthNames = "JanFebMarAprMayJunJulAugSepOctNovDec";

  28. var today = new Date();

  29. var thisDay;

  30. var monthDays = new montharr(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

  31. year = today.getYear() +1900;

  32. thisDay = today.getDate();

  33. if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) monthDays[1] = 29;

  34. nDays = monthDays[today.getMonth()];

  35. firstDay = today;

  36. firstDay.setDate(1);

  37. testMe = firstDay.getDate();

  38. if (testMe == 2) firstDay.setDate(0);

  39. startDay = firstDay.getDay();

  40. document.write("<div id='rili'>")

  41. document.write("<TABLE width='217' BORDER='0' CELLSPACING='0' CELLPADDING='2' BGCOLOR='#0080FF'>")

  42. document.write("<TR><TD><table border='0' cellspacing='1' cellpadding='2' bgcolor='Silver'>");

  43. document.write("<TR><th colspan='7' bgcolor='#C8E3FF'>");

  44. var dayNames = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");

  45. var monthNames = new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");

  46. var now = new Date();

  47. document.writeln("<FONT STYLE='font-size:9pt;Color:#330099'>" + "公元 " + now.getYear() + "年" + monthNames[now.getMonth()] + " " + now.getDate() + "日 " + dayNames[now.getDay()] + "</FONT>");

  48. document.writeln("</TH></TR><TR><TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>日</FONT></TH>");

  49. document.writeln("<th bgcolor='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>一</FONT></TH>");

  50. document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>二</FONT></TH>");

  51. document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>三</FONT></TH>");

  52. document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>四</FONT></TH>");

  53. document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>五</FONT></TH>");

  54. document.writeln("<TH BGCOLOR='#0080FF'><FONT STYLE='font-size:9pt;Color:White'>六</FONT></TH>");

  55. document.writeln("</TR><TR>");

  56. column = 0;

  57. for (i=0; i<startDay; i++) {

  58. document.writeln("\n<TD><FONT STYLE='font-size:9pt'> </FONT></TD>");

  59. column++;

  60. }



  61. for (i=1; i<=nDays; i++) {

  62. if (i == thisDay) {

  63. document.writeln("</TD><TD ALIGN='CENTER' BGCOLOR='#FF8040'><FONT STYLE='font-size:9pt;Color:#ffffff'><B>")

  64. }

  65. else {

  66. document.writeln("</TD><TD BGCOLOR='#FFFFFF' ALIGN='CENTER'><FONT STYLE='font-size:9pt;font-family:Arial;font-weight:bold;Color:#330066'>");

  67. }

  68. document.writeln(i);

  69. if (i == thisDay) document.writeln("</FONT></TD>")

  70. column++;

  71. if (column == 7) {

  72. document.writeln("<TR>");

  73. column = 0;

  74. }

  75. }

  76. document.writeln("<TR><TD COLSPAN='7' ALIGN='CENTER' VALIGN='TOP' BGCOLOR='#0080FF'>")

  77. document.writeln("<FORM NAME='clock' onSubmit='0'><FONT STYLE='font-size:9pt;Color:#ffffff'>")

  78. document.writeln("现在时间:<INPUT TYPE='Text' NAME='face' ALIGN='TOP'></FONT></FORM></TD></TR></TABLE>")

  79. document.writeln("</TD></TR></TABLE></div>");

  80. }

  81. </SCRIPT>

  82. <SCRIPT LANGUAGE="JavaScript">

  83. var timerID = null;

  84. var timerRunning = false;



  85. function stopclock (){

  86. if(timerRunning)

  87. clearTimeout(timerID);

  88. timerRunning = false;}



  89. //显示当前时间

  90. function showtime () {

  91. var now = new Date();

  92. var hours = now.getHours();

  93. var minutes = now.getMinutes();

  94. var seconds = now.getSeconds()

  95. var timeValue = " " + ((hours >12) ? hours -12 :hours)

  96. timeValue += ((minutes < 10) ? ":0" : ":") + minutes

  97. timeValue += ((seconds < 10) ? ":0" : ":") + seconds

  98. timeValue += (hours >= 12) ? " 下午 " : " 上午 "

  99. document.clock.face.value = timeValue;

  100. timerID = setTimeout("showtime()",1000);//设置超时,使时间动态显示

  101. timerRunning = true;}



  102. function startclock () {

  103. stopclock();

  104. showtime();}

  105. </SCRIPT>

  106. </head>



  107. <body onLoad="startclock(); timerONE=window.setTimeout">



  108. <script language="JavaScript" type="text/javascript">

  109. <!--

  110. calendar();

  111. //-->



  112. </script>



  113. </body>



  114. </html>
复制代码
发表于 2009-9-10 10:59:12 | 显示全部楼层
注意我修改的第 10 11 12 和78 行
头像被屏蔽
发表于 2009-9-10 11:30:01 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|免费吧论坛

GMT+8, 2024-5-14 01:41 , Processed in 0.024784 second(s), 4 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表