⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2time.htm

📁 简单的讲解语言,非常实用,使你在短期内就能熟练掌握其变成技巧
💻 HTM
字号:
<html>
<head>
<title>洪恩在线 - Javascript实例</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="/pub/css/home.css">
<link rel="stylesheet" href="../homepage.css">
</head>

<body bgcolor="#FFFFFF" onload="show()">
<script language="Javascript" src="/pub/js/head.js"></script>
<table width="760" height="20" border=0 cellspacing="0" cellpadding="0" align="center">
  <tr bgcolor="CFDFFF"> 
    <td height=20 class="p1" align="left"><img src="/pc/img/blank.gif" width="12" height="8"><font color="#000000"><font color="#FF9966">当前位置</font>:<a href="/default.htm" class="under">洪恩在线</a> 
      -&gt; <a href="/pc/index.htm" class="under">电脑乐园</a> -&gt; JavaScript实例</font></td>
  </tr>
</table>
<table width="760" border=0 cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td width="207" valign="top"><img src="img/bule.gif" width="207" height="13"></td>
    <td bgcolor="A8A8AB" width="1"><img src="img/blank.gif" width="1" height="1"></td>
    <td align="right" height="22" width=530><img src="img/js.gif" width="186" height="20"></td>
    <td width="22"><img src="img/blank.gif" width="1" height="1"></td>
  </tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td width="124"><img src="img/blank.gif" width="1" height="1"></td>
    <td background="img/line.gif" height="27" width=636><img src="img/blank.gif" width="1" height="1"></td>
  </tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td class=p3 align="center" width=711><b>     动 态 数 字 时 钟</b></td>
    <td class="p2" width="1" bgcolor="A8A8AB"><img src="img/blank.gif" width="1" height="1"></td>
    <td class="p2" width="48">&nbsp;</td>
  </tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td align="center" valign="top">&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="5F74BF" width="28" align="center"><img src="img/bule1.gif" width="28" height="49"></td>
    <td width="37" align="center">&nbsp;</td>
  </tr>
  <tr> 
    <td align="center" valign="top"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr align="center"> 
          <td> 
            <table width="110" border="0" cellspacing="0" cellpadding="0">
              <tr bgcolor="5F74BF" align="center"> 
                <td class="p1" align="right"><b><font color="#FFFFFF">效 果 演 示</font></b><font color="#FFFFFF">:</font></td>
                <td class="p1" width="11"><img src="img/bule2.gif" width="11" height="18"></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <td> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="59" > </td>
          <td  height="98" width=157 ><img src="img/time.gif" width="146" height="98"></td>
          <td  height="98" width="241" > 
            <script language="JavaScript">
<!--
function show(){
 if (!document.layers&&!document.all)
 return
 var timer=new Date()
 var hours=timer.getHours()
 var minutes=timer.getMinutes()
 var seconds=timer.getSeconds()
 var noon="AM" 
 if (hours>12){
 noon="PM"
 hours=hours-12
 }
 if (hours==0)
 hours=12
 if (minutes<=9)
 minutes="0"+minutes
 if (seconds<=9)
 seconds="0"+seconds
myclock="<font class=p3  color=blue><b>"+hours+":"+minutes+":"
 +seconds+noon+"</b></font>"
if (document.layers){
document.layers.position.document.write(myclock)
document.layers.position.document.close()
}
else if (document.all)
position.innerHTML=myclock
setTimeout("show()",1000)
 }
//-->
</script>
<p> <span id="position" style="position:absolute;left:441px;top:320px; width: 128px; height: 30px"> </span> </p>
          </td>
        </tr>
      </table>
      <span class="p1"><font color="#6633FF">建议使用1024*768的分辨率。</font></span><br>
      
    </td>
    <td bgcolor="5F74BF" width="28" align="center">&nbsp;</td>
    <td width="37" align="center">&nbsp;</td>
  </tr>
  <tr> 
    <td align="center" valign="top"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td height="30">&nbsp;</td>
        </tr>
        <tr align="center"> 
          <td> 
            <table width="110" border="0" cellspacing="0" cellpadding="0">
              <tr bgcolor="5F74BF" align="center"> 
                <td class="p1" align="right"><b><font color="#FFFFFF">源代码如下</font></b><font color="#FFFFFF">:</font></td>
                <td class="p1" width="11"><img src="img/bule2.gif" width="11" height="18"></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <td width="457" class="p2" valign="top"><b><br>
      <br>
      </b><span class="p1"><font color="#6633FF"><br>
      这段程序放在&lt;body&gt;与&lt;/body&gt;之间</font></span><br>
      <form>
        <textarea name="textarea" onFocus="this.select()" onMouseOver="this.focus()" cols="50" rows="12" wrap="VIRTUAL" style="BACKGROUND-COLOR: #D5E9FD;" >&lt;script language=&quot;JavaScript&quot;&gt;
&lt;!--

function Time(){
 if (!document.layers&amp;&amp;!document.all)
 return
 var Timer=new Date()
 var hours=Timer.getHours()
 var minutes=Timer.getMinutes()
 var seconds=Timer.getSeconds()
 var noon=&quot;AM&quot; 
 if (hours&gt;12){
 noon=&quot;PM&quot;
 hours=hours-12
 }
 if (hours==0)
 hours=12
 if (minutes&lt;=9)
 minutes=&quot;0&quot;+minutes
 if (seconds&lt;=9)
 seconds=&quot;0&quot;+seconds
//change font size here to your desire
myclock=&quot;&lt;font size='4' face='Arial' color=blue&gt;&quot;+hours+&quot;:&quot;+minutes+&quot;:&quot;
 +seconds+&quot; &quot;+noon+&quot;&lt;/b&gt;&lt;/font&gt;&quot;
if (document.layers){
document.layers.position.document.write(myclock)
document.layers.position.document.close()
}
else if (document.all)
position.innerHTML=myclock
setTimeout(&quot;Time()&quot;,1000)
 }
//--&gt;
&lt;/script&gt;
&lt;span id=&quot;position&quot; style=&quot;position:absolute;left:441px;top:190px; width: 128px; height: 30px&quot;&gt; 
&lt;/span&gt; </textarea>
      </form>
      <br>
      </td>
    <td bgcolor="5F74BF" width="28" align="center">&nbsp;</td>
    <td width="37" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td align="center" valign="bottom"> 
      <table width="238" border="0" cellspacing="0" cellpadding="0" class=p2>
        <tr align="center"> 
          <td> 
            <table width="110" border="0" cellspacing="0" cellpadding="0" class=p2>
              <tr bgcolor="5F74BF" align="center"> 
                <td class="p1" align="right"><b><font color="#FFFFFF">源程序讲解:</font></b></td>
                <td class="p1" width="11"><img src="img/bule2.gif" width="11" height="18"></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <td width="457" class="p2" valign="top">&nbsp;</td>
    <td bgcolor="5F74BF" width="28" align="center"><img src="img/bule1.gif" width="28" height="49"></td>
    <td width="37" align="center">&nbsp;</td>
  </tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td class="p2" align="right" width="693"> <br>
      <table width="650" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td> 
            <table width="100%" border="1" cellspacing="1" cellpadding="1" bordercolorlight="#666666" bordercolordark="#666666" class=p2>
              <tr> 
                <td width="369"> 
                  <p>function Time() </p>
                </td>
                <td width="391">定义一个函数。</td>
              </tr>
              <tr bgcolor="CFDFFF"> 
                <td width="369">{ if (!document.layers&amp;&amp;!document.all)<br>
                  return<br>
                </td>
                <td width="391"> 
                  <p>由于IE与Netscape对JavaScript的解释不同,造成浏览的效果不同,所以要分别写代码。这句话判断一下用户所使用的浏览器,如果两者都不是,就返回。</p>
                </td>
              </tr>
              <tr> 
                <td width="369">var timer=new Date()<br>
                </td>
                <td width="391">定义一个新的变量,名字为timer,为一个新的Date的对象。</td>
              </tr>
              <tr bgcolor="CFDFFF"> 
                <td width="369">var hours=Timer.getHours() <br>
                  var minutes=Timer.getMinutes()<br>
                  var seconds=Timer.getSeconds() <br>
                </td>
                <td width="391">分别定义3个变量,获得当前“小时”,“分钟”,“秒”的值。</td>
              </tr>
              <tr> 
                <td width="369">var noon=&quot;AM&quot; if (hours&gt;12)<br>
                  { noon=&quot;PM&quot; hours=hours-12 }<br>
                  if (hours==0) <br>
                  hours=12<br>
                </td>
                <td width="391">定义一个名为“noon”的变量,当“小时”数大于12时,其值为PM,同时所得值减12;当“小时”数小于12时,其值为AM。</td>
              </tr>
              <tr bgcolor="CFDFFF"> 
                <td width="369">if (minutes&lt;=9)<br>
                  minutes=&quot;0&quot;+minutes<br>
                  if (seconds&lt;=9) <br>
                  seconds=&quot;0&quot;+seconds <br>
                </td>
                <td width="391">如果“分钟”数或“秒”数小于9,则在前面加一个“0”。</td>
              </tr>
              <tr> 
                <td width="369"> 
                  <p> myclock=&quot;&lt;font color=blue&gt;&quot;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -