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

📄 5hello.htm

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

<body bgcolor="#FFFFFF" ><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 class=p2 > 
      <p>&nbsp;</p>
      <p><script language="JavaScript"><!--
var mess1="";
document.write("<center><font color='#FF0000' size=4><b>")
day = new Date( )
hr = day.getHours( )
if (( hr >= 0 ) && (hr <= 4 ))
mess1="深夜了,注意身体,该休息了!"
if (( hr >= 4 ) && (hr < 7))
mess1="清晨好,这麽早就上网呀?! "
if (( hr >= 7 ) && (hr < 12))
mess1="早上好,一天之际在于晨,又是美好的一天!"
if (( hr >= 12) && (hr <= 13))
mess1="该吃午饭啦!有什麽好吃的?"
if (( hr >= 13) && (hr <= 17))
mess1="外面的天气很热吧?!心静自然凉! "
if (( hr >= 17) && (hr <= 18))
mess1="太阳落山了!快看看夕阳吧!"
if ((hr >= 18) && (hr <= 19))
mess1="吃过晚饭了吗?"
if ((hr >= 19) && (hr <= 23))
mess1="一天过的可真快!今天过的好吗?"
document.write(mess1)
document.write("</b></font></center>")
//---></script>
      </p>
      <p>&nbsp;</p>
      </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><b><br>
      </b>
      <form>
        <p>
          <textarea name="textarea" onFocus="this.select()" onMouseOver="this.focus()" cols="50" rows="10" wrap="VIRTUAL" style="BACKGROUND-COLOR: #D5E9FD;" >&lt;script language=&quot;JavaScript&quot;&gt;
&lt;!--
var mess1=&quot;&quot;;
document.write(&quot;&lt;center&gt;&lt;font color='#0000FF' size=4&gt;&lt;b&gt;&quot;)
day = new Date( )
hr = day.getHours( )
if (( hr &gt;= 0 ) &amp;&amp; (hr &lt;= 4 ))
mess1=&quot;深夜了,注意身体,该休息了!&quot;
if (( hr &gt;= 4 ) &amp;&amp; (hr &lt; 7))
mess1=&quot;清晨好,这麽早就上网呀?! &quot;
if (( hr &gt;= 7 ) &amp;&amp; (hr &lt; 12))
mess1=&quot;早上好,一天之际在于晨,又是美好的一天!&quot;
if (( hr &gt;= 12) &amp;&amp; (hr &lt;= 13))
mess1=&quot;该吃午饭啦!有什麽好吃的?&quot;
if (( hr &gt;= 13) &amp;&amp; (hr &lt;= 17))
mess1=&quot;外面的天气很热吧?!心静自然凉! &quot;
if (( hr &gt;= 17) &amp;&amp; (hr &lt;= 18))
mess1=&quot;太阳落山了!快看看夕阳吧!&quot;
if ((hr &gt;= 18) &amp;&amp; (hr &lt;= 19))
mess1=&quot;吃过晚饭了吗?&quot;
if ((hr &gt;= 19) &amp;&amp; (hr &lt;= 23))
mess1=&quot;一天过的可真快!今天过的好吗?&quot;
document.write(mess1)
document.write(&quot;&lt;/b&gt;&lt;/font&gt;&lt;/center&gt;&quot;)
//---&gt;
&lt;/script&gt;</textarea>
          </p>
        <p>&nbsp;</p>
        </form>
      <b><br>
      </b></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">
        <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></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="386"> 
                  <p>var mess1="";<br>
                  </p>
                </td>
                <td width="374">定义一个新变量。</td>
              </tr>
              <tr bgcolor="CFDFFF"> 
                <td width="386">document.write("&lt;center&gt;&lt;b&gt; <font color='#0000FF'><font color="000000">")<br>
                  </font></font></td>
                <td width="374">设置格式,可以是字体,颜色等。</td>
              </tr>
              <tr> 
                <td width="386"><font color='#0000FF'><font color="000000">day 
                  = new Date( ) <br>
                  </font></font></td>
                <td width="374">设置Date的一个新对象。</td>
              </tr>
              <tr bgcolor="CFDFFF"> 
                <td width="386"><font color='#0000FF'><font color="000000">hr 
                  = day.getHours( )<br>
                  </font></font></td>
                <td width="374">把当前的“小时”的值赋给hr.</td>
              </tr>
              <tr> 
                <td width="386"><font color='#0000FF'><font color="000000">if 
                  (( hr >= 0 ) && (hr <= 4 ))<br>
                  mess1="深夜了,</font></font>注<font color='#0000FF'><font color="000000">意身体,该休息了!"<br>
                  </font></font></td>
                <td width="374">在0--4点间,出现“<font color='#0000FF'><font color="000000">清晨好,这麽早就上网呀?!</font></font>”字样。以下,类推。</td>
              </tr>
              <tr bgcolor="CFDFFF"> 
                <td width="386"><font color='#0000FF'><font color="000000">if 
                  (( hr >= 4 ) && (hr < 7)) <br>
                  mess1="清晨好,这麽早就上网呀?!"<br>
                  if (( hr >= 7 ) && (hr < 12)) <br>
                  mess1="早上好,一天之际在于晨,又是美好的一天!" <br>
                  if (( hr >= 12) && (hr <= 13))<br>
                  mess1="该吃午饭啦!有什麽好吃的?" <br>
                  if (( hr >= 13) && (hr <= 17))<br>
                  mess1="外面的天气很热吧?!心静自然凉! "<br>
                  if (( hr >= 17) && (hr <= 18))<br>
                  mess1="太阳落山了!快看看夕阳吧!"<br>
                  if ((hr >= 18) && (hr <= 19))<br>
                  mess1="吃过晚饭了吗?"<br>
                  if ((hr >= 19) && (hr <= 23))<br>
                  mess1="一天过的可真快!今天过的好吗?"<br>
                  </font></font></td>
                <td width="374">同上。</td>
              </tr>
              <tr> 
                <td width="386"><font color='#0000FF'><font color="000000">document.write(mess1)</font></font><font color='#0000FF' size=4><br>
                  </font></td>
                <td width="374">输出mess1的值。</td>
              </tr>
              <tr bgcolor="CFDFFF"> 
                <td width="386"><font color="000000">document.write("</font>&lt;/b&gt; 
                  ")</td>
                <td width="374">字体设置结束。</td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      <br>
      <br>
    </td>
    <td class="p2" width="18">&nbsp;</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 bgcolor="5F74BF"> 
    <td>&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>

⌨️ 快捷键说明

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