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

[程序代码] 怎么让这个模块在网页中左对齐(或者取消他的定位)

[复制链接]
发表于 2009-9-9 20:16:13 | 显示全部楼层 |阅读模式
  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-10 10:45:18 | 显示全部楼层
很简单呀, 38行改为。
document.write("<div id='rili' style='position:absolute;width:140px;left:0px;top:0px;'>")
发表于 2009-9-10 16:32:30 | 显示全部楼层
这个帖子好眼熟……
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-13 10:34 , Processed in 0.027464 second(s), 6 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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