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

📄 day2_2.html

📁 JAVASCRIPT 高级编程
💻 HTML
📖 第 1 页 / 共 2 页
字号:
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/internet/index.htm">Internet应用</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/photoshop/index.html">Photoshop</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/flash/page1.html">Flash</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/asp/index.html">ASP</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/php/index.html">PHP</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/java/index.htm">Java</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/vb/index.htm">VB</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/c/index.htm">C、C++</a></td>
  </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>第二页:神奇的字符串处理</strong> 
      <p>为什么必须在开始cookies世界漫游之前必须先学习神奇的字符<br>
        串处理呢?因为cookies也是字符串。要保存访问者的信息,你<br>
        必须首先建立一个特殊的cookie字符串。然后在访问者又返回<br>
        你的站点时读取该信息,而此时你必须对该cookie字符串进行<br>
        解码。要生成和解释这些字符串你必须了解JavaScript的字符<br>
        串工作原理。所以我们必须先要了解字符串。如果你是一个新<br>
        手,你应该先阅读一下上次的javascript教程第2日的内容,一<br>
        下是一个例子:</p>
      <p>var normal_monkey = &quot;I am a monkey!&lt;br&gt;&quot;;<br>
        <br>
        document.writeln(&quot;Normal monkey &quot; + normal_monkey);<br>
        <br>
        var bold_monkey = normal_monkey.bold();<br>
        <br>
        document.writeln(&quot;Bold monkey &quot; + bold_monkey);<br>
        <br>
        这里的声明: <br>
        <br>
        var bold_monkey = normal_monkey.bold();<br>
        <br>
        和下面对声明是等同的: <br>
        <br>
        var bold_monkey = &quot;&lt;b&gt;&quot; + normal_monkey + &quot;&lt;/b&gt;&quot;;</p>
      <p>第1个版本的声明看起来要简明得多。这里用到了字符串对象中<br>
        的bold对象,其他的字符串对象还有indexOf, charAt, <br>
        substring, 以及split, 这些方法可以深入字符串的组成结构。<br>
        首先我们研究一下indexOf。</p>
      <p>indexOf <br>
        indexOf用于发现一系列的字符在一个字符串中等位置并告诉你<br>
        子字符串的起始位置。如果一个字符串中部包含该子字符串则<br>
        indexOf返回returns &quot;-1.&quot; 这里是一个例子:</p>
      <p>var the_word = &quot;monkey&quot;; </p>
      <p>让我们从单词 &quot;monkey&quot;开始。 </p>
      <p>var location_of_m = the_word.indexOf(&quot;m&quot;); </p>
      <p>location_of_m(字母m的位置)将为0,因为字母m位于该字符串<br>
        的起始位置。var location_of_o = the_word.indexOf(&quot;o&quot;); <br>
        location_of_o(字母o的位置)将为1。</p>
      <p>var location_of_key = the_word.indexOf(&quot;key&quot;); </p>
      <p>location_of_key(key的位置)将为3因为子字符串“key”以字母<br>
        k开始,而k在单词monkey中的位置是3。</p>
      <p>var location_of_y = the_word.indexOf(&quot;y&quot;); <br>
        location_of_y)字母y的位置)是5。 <br>
        var cheeky = the_word.indexOf(&quot;q&quot;); <br>
        cheeky值是-1,因为在单词“monkey”中没有字母q。<br>
        <br>
        indexOf更实用之处:<br>
        var the_email = prompt(&quot;What's your email address?&quot;, &quot;&quot;);<br>
        <br>
        var the_at_is_at = the_email.indexOf(&quot;@&quot;);<br>
        <br>
        if (the_at_is_at == -1)<br>
        <br>
        {<br>
        <br>
        &nbsp;&nbsp;&nbsp; alert(&quot;You loser, email addresses must <br>
        &nbsp;&nbsp;&nbsp; have @ signs in them.&quot;);<br>
        <br>
        }<br>
      </p>
      <p>这段代码询问用户的电子邮件地址,如果用户输入的电子邮件<br>
        地址中不包含字符 则 提示用户"@你输入的电子邮件地址<br>
        无效,电子邮件的地址必须包含字符@。"<br>
        <br>
        charAt <br>
        chatAt方法用于发现一个字符串中某个特定位置的字符。这里<br>
        是一个例子:<br>
        <br>
        <br>
        var the_word = &quot;monkey&quot;;<br>
        <br>
        var the_first_letter = the_word.charAt(0);<br>
        <br>
        var the_second_letter = the_word.charAt(1);<br>
        <br>
        var the_last_letter = the_word.charAt(the_word.length-1);<br>
        <br>
        the_first_letter(第1个字符)是&quot;m&quot;<br>
        the_second_letter(第2个字符)是&quot;o&quot;<br>
        the_last_letter(最后一个字符)是 &quot;y&quot;<br>
        <br>
        注意利用字符串的length(长度)属性你可以发现在包含多少个<br>
        字符。在本例中,the_word是&quot;monkey&quot;,所以the_word.length<br>
        是6。不要忘记在一个字符串中第1个字符的位置是0,所以最后<br>
        一个字符的位置就是length-1。所以在最后一行中用了<br>
        the_word.length-1。<a href="day2_3.html">&gt;&gt;</a></p>
      <p><font face="宋体" size="3" color="#000000"><strong>JavaScript高级教程</strong></font><font color="#FF0000" face="宋体" size="3"><br>
        </font><font color="#FF0000">第一页</font> <a href="day2_1.html">Javascript高级教程-第2日</a><br>
        <font color="#FF0000">第二页</font> 神奇的字符串处理<br>
        <font color="#FF0000">第三页</font> <a href="day2_3.html">子字符串</a><br>
        <font color="#FF0000">第四页</font> <a href="day2_4.html">分割方法(splitting 
        method)</a><br>
        <font color="#FF0000">第五页</font> <a href="day2_5.html">相关数组</a><br>
        <font color="#FF0000">第六页</font> <a href="day2_6.html">相关数组的一个例子</a><br>
        <font color="#FF0000">第七页</font> <a href="day2_7.html">介绍cookie</a><br>
        <font color="#FF0000">第八页</font> <a href="day2_8.html">深入了解cookies</a><br>
        <font color="#FF0000">第九页</font> <a href="day2_9.html">读取cookies</a><br>
        <font color="#FF0000">第十页</font> <a href="day2_10.html">复杂的cookies读取</a><br>
        <font color="#FF0000">第十一页</font> <a href="day2_11.html">读取和编写多重cookies</a><br>
        <font color="#FF0000">第十二页</font> <a href="day2_12.html">再次深入了解cookies</a><br>
        <font color="#FF0000">第十三页</font> <a href="day2_13.html">cookie路径和域</a></p>
      <p><font size="3">[<a href="day1_1.html">第1课</a>][第2课][<a href="day3_1.html">第3课</a>][<a href="day4_1.html">第4课</a>][<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 + -