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

📄 day2_11.html

📁 JAVASCRIPT 高级编程
💻 HTML
📖 第 1 页 / 共 2 页
字号:
    <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>第十一页:读取和编写多重cookies</strong> 
      <p>上一篇中我们学习了如何将大量的学习包含在一个cookie中.<br>
        另一种方法是使用多重cookies.<br>
        <br>
        保存多重cookies的方法很直观.每一个cookie都有一个名称.<br>
        上一个例子中的cookie的名称是my_happy_cookie,我们可以<br>
        这样:<br>
        var the_cookie =&quot;my_happy_cookie=happiness_and_joy&quot;;<br>
        <br>
        document.cookie =the_cookie;<br>
        <br>
        要保存多重cookie,只需给每个cookie一个不同的名字.如果<br>
        你要加入一个新的cookie,设置document.cookie 时并不会删<br>
        除前面已经设置了的cookies,所以:<br>
        <br>
        var the_cookie =&quot;my_happy_cookie=happiness_and_joy&quot;;<br>
        <br>
        document.cookie = the_cookie;<br>
        <br>
        var another_cookie= &quot;my_other_cookie=more_joy_more_happiness&quot;;<br>
        <br>
        document.cookie = another_cookie;<br>
        <br>
        现在你需要访问这两个cookies,有些复杂,所以你需要明了整<br>
        个过程.假设你执行了上面的代码,现在想访问<br>
        my_happy_cookie.如果你查看document.cookie的内容,你会<br>
        看到:<br>
        <br>
        my_happy_cookie=happiness_and_joy;<br>
        my_other_cookie=more_joy_more_happiness;<br>
        <br>
        这样很直观,但是如果你想访问某个特定的cookie则有些困难.<br>
        下面的代码可以帮助你找出某个特定的cookie:<br>
        function WM_readCookie(name)<br>
        {<br>
        <br>
        //如果没有cookie则返回false或者取得值并返回该值<br>
        if(document.cookie == '')<br>
        &nbsp;&nbsp;&nbsp; return false;<br>
        else<br>
        &nbsp;&nbsp;&nbsp; return<br>
        unescape(WM_getCookieValue(name));<br>
        }<br>
        <br>
        <br>
        <br>
        function WM_getCookieValue(name)<br>
        {<br>
        <br>
        // Declare variables.<br>
        <br>
        var firstChar,lastChar;<br>
        <br>
        // Get the entire cookie string.<br>
        // (This may have other<br>
        name=value pairs in it.)<br>
        <br>
        var theBigCookie = document.cookie;<br>
        <br>
        // Grab<br>
        just this cookie from theBigCookie string.<br>
        <br>
        // Find the start of<br>
        'name'.<br>
        <br>
        firstChar = theBigCookie.indexOf(name);<br>
        <br>
        // If you found it,<br>
        <br>
        <br>
        if(firstChar != -1)<br>
        {<br>
        <br>
        // skip 'name' and '='.<br>
        <br>
        firstChar +=<br>
        name.length + 1;<br>
        <br>
        // Find the end of the value string (i.e. the next<br>
        ';').<br>
        <br>
        lastChar = theBigCookie.indexOf(';', firstChar);<br>
        <br>
        <br>
        if(lastChar == -1) lastChar = theBigCookie.length;<br>
        <br>
        // Return the<br>
        value.<br>
        <br>
        return theBigCookie.substring(firstChar, lastChar);<br>
        <br>
        } else<br>
        {<br>
        <br>
        // If there was no cookie, return false.<br>
        <br>
        return false;<br>
        <br>
        <br>
        <br>
        }<br>
        <br>
        }<br>
        <br>
        下面我们将学习一下cookies可以做的真正酷的内容。<a href="day2_12.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> <a href="day2_2.html">神奇的字符串处理</a><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> 读取和编写多重cookies<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 + -