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

📄 day4_12.html

📁 不错的javascript学习资料适合于刚刚学习javascirpt的出学者
💻 HTML
📖 第 1 页 / 共 2 页
字号:
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-backend/database/php_mysql/index.html">PHP/MySQL</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2"><a href="../../1-backend/cgi_perl/perl_beginner/index.html">-Perl</a> 
    </td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/other/index.htm">其它</a> </td>
  </tr>
  <tr> 
    <td colspan="2" bgcolor="#666699"> 
      <div align="center"><font color="#FFFFFF">更多教程</font></div>
    </td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" height="17"><a href="../../1hdml/index.html">-HDML</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" height="23"><font face="宋体"><a href="../../1-backend/database/course/day1_1.html">-网络数据库</a></font></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" height="14"><a href="../../1-backend/protocols/ping/index.html"><font face="arial, helvetica, sans-serif">-ping</font></a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" height="20"><a href="../../1-backend/cgi_perl/search_engine/index.html">-创建搜索引擎</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" height="16">-<a href="../../1adobe/GoLive/index.html">Adobe GoLive</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2"><a href="../../1-backend/cgi_perl/templates/index.html">-模板</a></td>
  </tr>
  <tr bgcolor="#666699"> 
    <td colspan="2" align="center"><font color="#FFFFFF">合作伙伴</font></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" align="left">-<a href="http://www.5dmedia.com/" target="_blank">5D精英网</a></td>
  </tr>
  <tr align="center" bgcolor="#FFFFFF"> 
    <td colspan="2"> <img src="../../Library/front_monkey.gif" width="59" height="68"></td>
  </tr>
  </tbody> 
</table>
<!-- #EndLibraryItem --> </td>
 <!-- End of headlines (column 1: left column) --> <!-- Gutter between columns 1 and 2 --> 
 <td width="10" height="794"><img src="http://www.sohu.com/images/pixel.gif" width=10></td>
 <!-- Search box and directories (columns 2 and 3: middle columns, combined into one) --> 
 <td align=center valign=top width="558"> 
 <div align="left"><!-- #BeginEditable "1" --> 
<title>JavaScrip教程</title>
 <strong><font face="宋体" size="3">第十二页:</font><font size="3">无参数函数</font></strong> 
      <p><font face="宋体" size="3"><nobr>该HTML页含有一个叫做announceTime的函数。从一个链接调用<br>
        annoumnceTime:</nobr></font></p>
      <p><nobr><font face="宋体"><br>
        &lt;a href=&quot;#&quot; onClick=&quot;announceTime();&quot;&gt;time!&lt;/a&gt;<br>
        <br>
        </font></nobr></p>
      <nobr> 
      <p align="JUSTIFY"><font size="3"><font face="宋体">就象这样:</font></font></p>
      <font size="3"> 
      <p align="JUSTIFY"><font face="宋体">下行看起来就象第二课:</font></p>
      </font> </nobr> 
      <p align="JUSTIFY"><nobr><font face="宋体"><br>
        &lt;a href=&quot;#&quot; onClick=&quot;alert('Hello!');&quot;&gt;Hello!&lt;/a&gt;<br>
        <br>
        </font></nobr></p>
      <nobr> 
      <p align="JUSTIFY"><font size="3"><font face="宋体">这称为从一个链接调用警告对话框。函数就象一种方法,唯一不<br>
        同的是,方法依附于一个对象。在这个警告的例子中,这个对象<br>
        是一个窗口对象。</font></font></p>
      <font size="3"> 
      <p align="JUSTIFY"><font face="宋体">让我们回到函数本身。如果你看看源码,你将看到函数位于HTML<br>
        文件的头部中。</font></p>
      </font></nobr> 
      <p align="JUSTIFY"><font face="宋体"><nobr><br>
        &lt;html&gt;<br>
        <br>
        &lt;head&gt;<br>
        <br>
        &lt;title&gt;Function with No Parameters&lt;/title&gt;<br>
        <br>
        &lt;script langauge=&quot;JavaScript&quot;&gt;<br>
        <br>
        &lt;!-- hide me<br>
        <br>
        function announceTime()<br>
        <br>
        {<br>
        <br>
        //get the date, the hour, minutes, and seconds<br>
        <br>
        var the_date = new Date();<br>
        <br>
        var the_hour = the_date.getHours();<br>
        <br>
        var the_minute = the_date.getMinutes();<br>
        <br>
        var the_second = the_date.getSeconds();<br>
        <br>
        <br>
        //put together the string and alert with it<br>
        <br>
        var the_time = the_hour + &quot;:&quot; + the_minute <br>
        + &quot;:&quot; + the_second;<br>
        <br>
        alert(&quot;The time is now: &quot; + the_time);<br>
        <br>
        }<br>
        <br>
        <br>
        // show me --&gt;<br>
        <br>
        &lt;/script&gt;<br>
        <br>
        <br>
        &lt;/head&gt;<br>
        <br>
        &lt;body&gt;<br>
        <br>
        ...<br>
        <br>
        &lt;/body&gt;<br>
        <br>
        &lt;/html&gt;<br>
        <br>
        <font size="3">好,让我们逐行复习这个函数。首先,所有函数来自于该种格式:</font></nobr></font></p>
      <p align="JUSTIFY"><nobr><font face="宋体"><br>
        function functionName(parameter list)<br>
        <br>
        {<br>
        <br>
        statements ...<br>
        <br>
        }<br>
        <br>
        </font></nobr></p>
      <nobr> 
      <p align="JUSTIFY"><font size="3"><font size="2"><font face="宋体">函数的命名规则于变量差不多。第一个字符必须是字母或一标准符<br>
        号。其余字符可为数字或一横线。但必须保证函数不于已定义的变<br>
        量同名。否则将出现很糟糕的结果。我是用内部大写的方式命名函<br>
        数以保证它们不与字符碰巧重名。</font></font></font></p>
      <font size="3"> 
      <p align="JUSTIFY"> <font size="2"></font><font face="宋体">函数名后是一组参数。本例是无参数的函数,下一例中我们再举例<br>
        描述。</font></p>
      <p align="JUSTIFY"><font face="宋体">参数后是函数的主体。这是一组当函数调用后是想运行的语句。在<br>
        下面几个例子中,我打算利用这个报时器,所以让我描述一下它是<br>
        怎样工作的。</font></p>
      <p align="JUSTIFY"><font face="宋体">第一行:</font></p>
      </font> </nobr> 
      <p align="JUSTIFY"><nobr><font face="宋体"><br>
        var the_date = new Date();<br>
        <br>
        </font></nobr></p>
      <nobr><font size="3"> 
      <p align="JUSTIFY"><font face="宋体">取得一个新的日期对象。就象你在用数组时取得一个新的数组一<br>
        样,在你要找出即时是什么时间时你需要先取得一个日期对象。<br>
        当找到了一个新的日期对象,它自动重置到当前的日期和时间。<br>
        为了在对象以外得到这个信息,你必须使用这种对象方法:</font></p>
      <p align="JUSTIFY"><font face="宋体">这些方法从日期对象上取得了合适的数字。</font></p>
      </font> </nobr> 
      <p align="JUSTIFY"><nobr><font face="宋体" size="2"><br>
        var the_hour = the_date.getHours();<br>
        <br>
        var the_minute = the_date.getMinutes();<br>
        <br>
        var the_second = the_date.getSeconds();<br>
        <br>
        </font></nobr></p><nobr>
      <p align="JUSTIFY"><font size="2"></font><font face="宋体" size="3">你可能疑惑:我怎样能假定日期对象知道何种方式?甚或我如何<br>
        知道有这样一件事可作为日期对象?这些缘由应从Javascript<br>
        库中获取,我将尽我所能解释内置Javascript对象,但不一定能<br>
        彻底的使你清楚。</font></p>
      <p align="JUSTIFY"> <font size="4"></font><font face="宋体" size="3">函数的其他部分就很清楚了。它以这种方式调用返回数字,把它<br>
        们变成字符串,并且调用警告方式以弹出一个字符串对话框。注<br>
        意你可以在函数内部调用一个方式和函数。我们将详尽讨论。</font></p>
      <p align="JUSTIFY"> <font size="1"></font><font face="宋体" size="3">现在如果你也玩透了时间链接,你可能注意到了有些什么不对的<br>
        事。你每次可能会得到这样的反馈:“12:12:04”,这是<br>
        getSecond()将返回值为“4”。那么当你合成为时间时,你看到<br>
        的就是the_minute+“:”+the_second得到14:4而非是我们想要<br>
        的。解决它是个容易的事,需要个新的函数来修补分、秒合成值。</font></p>
      <p align="JUSTIFY"> <font size="2"></font><font face="宋体" size="3">请看</nobr><a href="day4_13.html">参数及返回值</a><nobr>。</nobr></font></p>
      <p align="left"><font face="宋体" size="3" color="#000000"><strong>JavaScript教程</strong></font><font color="#FF0000" face="宋体" size="3"><br>
        </font><font size="3" color="#FF0000">第一页</font><font size="2" face="宋体"> 
        </font><a href="day4_12.html"><font size="3">第四课介绍</font></a><font size="2"><br>
        </font><font size="3"><font color="#FF0000">第二页</font> <a href="day4_2.html">循环介绍</a></font><font size="2"><br>
        </font><font size="3"><font color="#FF0000">第三页</font> <a href="day4_3.html">循环的密码</a></font><font size="2"><br>
        </font><font size="3"><font color="#FF0000">第四页</font> <a href="day4_4.html">再谈<font face="宋体">WHILE</font>循环</a></font><font size="2"><br>
        </font><font size="3"><font color="#FF0000">第五页</font> <a href="day4_5.html">For循环</a></font><font size="2"><br>
        </font><font size="3"><font color="#FF0000">第六页</font> <a href="day4_6.html">嵌套循环</a></font><font size="2"><br>
        </font><font size="3"><font color="#FF0000">第七页</font> <a href="day4_7.html">循环练习</a></font><font size="2"><br>
        </font><font size="3"><font color="#FF0000">第八页</font> <a href="day4_8.html">数组</a></font><font size="2"><br>
        </font><font size="3"><font color="#FF0000">第九页</font> <a href="day4_9.html">数组和循环</a></font><font size="2"><br>
        </font><font size="3"><font color="#FF0000">第十页</font> <a href="day4_10.html">文件目标模块中的数组</a></font><font size="2"><br>
        </font><font size="3"><font color="#FF0000">第十一页</font> <a href="day4_11.html">函数</a></font><font size="2"><br>
        </font><font size="3"><font color="#FF0000">第十二页</font> 无参数函数</font><font size="2"><br>
        </font><font size="3"><font color="#FF0000">第十三页</font> <a href="day4_13.html">参数及返回值</a></font><font size="2"><br>
        </font><font size="3"><font color="#FF0000">第十四页</font> <a href="day4_14.html">多于一个参数的函数</a></font></p>
      <p align="left"><font face="宋体" size="3">[<a href="index.html">第1课</a>][<a href="day2_1.html">第2课</a>][<a href="day3_1.html">第3课</a>][第4课][<a href="day5_1.html">第5课</a>]</font></p>
      <!-- #EndEditable --></div>
 </td>
 <!-- End of search box and directories (columns 2 and 3: middle columns, combined into one) --> 
 <!-- Gutter between columns 3 and 4 --> <!-- Other stuff (column 4: right column) --> 
 <!-- End of other stuff (column 4: right column) --> </tr>
 </table>
<!-- End of table surrounding page contents -->

 <hr noshade size=1 width=700>
 <span class=eng><br>
 Copyright (C) 1998-2000 Internet Technologies China.&nbsp; All rights reserved. 
 </span> 
</center>
</body>
<!-- #EndTemplate --></html>

⌨️ 快捷键说明

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