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

📄 5.htm

📁 javascript book
💻 HTM
📖 第 1 页 / 共 3 页
字号:
      <p style="line-height: 150%"><font face="宋体" size="3">function   
      university(name,city,createDate,URL)</font></p>  
      <!--mstheme--></font> 
      <!--msthemelist--><table border="0" cellpadding="0" cellspacing="0" width="100%">
        <!--msthemelist--><tr>
          <!--msthemelist--><td valign="baseline" width="42"><img src="amaizbu1.gif" width="15" height="15" hspace="13"></td>
          <td valign="top" width="100%"><!--mstheme--><font face="宋体"> 
          <p style="line-height: 150%"><font size="3"> </font>
            <!--mstheme--></font>
            <!--msthemelist--><table border="0" cellpadding="0" cellspacing="0" width="100%">
              <!--msthemelist--><tr>
                <!--msthemelist--><td valign="baseline" width="42"><img src="amaizbu2.gif" width="12" height="12" hspace="15"></td>
                <td valign="top" width="100%"><!--mstheme--><font face="宋体">
              <p style="line-height: 150%"><font face="宋体" size="3">This.Name=Name;</font>
              <p style="line-height: 150%"><font face="宋体" size="3">This.city=city;</font></p>
              <p style="line-height: 150%"><font face="宋体" size="3">This.createDate=New   
              Date(creatDate);</font></p>  
              <p style="line-height: 150%"><font face="宋体" size="3">This.URL=URL;</font></p>  
              <p style="line-height: 150%"><font face="宋体" size="3">This.showuniversity=showuniversity;</font></p>  
                  <!--mstheme--></font><!--msthemelist--></td> 
              </tr> 
            <!--msthemelist--></table> 
            <!--mstheme--><font face="宋体"><!--mstheme--></font><!--msthemelist--></td>
        </tr>
      <!--msthemelist--></table>
      <!--mstheme--><font face="宋体"> 
      <p style="line-height: 150%"><font face="宋体" size="3">其中This.showuniversity就是定义了一个方法---showuniversity()。</font></p> 
      <p style="line-height: 150%"><font face="宋体" size="3">而showuniversity()方法是实现university对象本身的显示。</font></p> 
      <p style="line-height: 150%"><font face="宋体" size="3">function showuniversity()</font></p>  
      <!--mstheme--></font> 
      <!--msthemelist--><table border="0" cellpadding="0" cellspacing="0" width="100%">
        <!--msthemelist--><tr>
          <!--msthemelist--><td valign="baseline" width="42"><img src="amaizbu1.gif" width="15" height="15" hspace="13"></td>
          <td valign="top" width="100%"><!--mstheme--><font face="宋体"> 
          <p style="line-height: 150%"><font size="3"> </font>
            <!--mstheme--></font>
            <!--msthemelist--><table border="0" cellpadding="0" cellspacing="0" width="100%">
              <!--msthemelist--><tr>
                <!--msthemelist--><td valign="baseline" width="42"><img src="amaizbu2.gif" width="12" height="12" hspace="15"></td>
                <td valign="top" width="100%"><!--mstheme--><font face="宋体">
              <p style="line-height: 150%"><font face="宋体" size="3">For (var prop in   
              this)</font>  
              <p style="line-height: 150%"><font face="宋体" size="3">alert(prop+=&quot;+this[prop]+&quot;&quot;);</font></p>  
                  <!--mstheme--></font><!--msthemelist--></td> 
              </tr> 
            <!--msthemelist--></table> 
            <!--mstheme--><font face="宋体"><!--mstheme--></font><!--msthemelist--></td>
        </tr>
      <!--msthemelist--></table>
      <!--mstheme--><font face="宋体"> 
      <p style="line-height: 150%"><font face="宋体" size="3">其中alert是JavaScript中的内部函数,显示其字符串。</font></p> 
      <p style="line-height: 150%"><font face="宋体" size="3"> </font></p> 
      <p style="line-height: 150%"><b><font face="宋体" size="3">四、JavaScript中的数组</font></b></p> 
      <ol> 
        <li> 
          <p style="line-height: 150%"><font face="宋体" size="3"> </font> 
        <li> 
          <p style="line-height: 150%"><font face="宋体" size="3"><b>使用New创建数组</b></font> 
        <li> 
          <p style="line-height: 150%"><font face="宋体" size="3">JavaScript中没有提供像其它语言具有明显的数组类型,但可以通过function定义一个数组,并使用New对象操作符创建一个具有下标的数组。从而可以实现任何数据类型的存储。</font> 
          <p style="line-height: 150%"><font face="宋体" size="3">a、定义对象的数组</font></p> 
          <p style="line-height: 150%"><font face="宋体" size="3">Function   
          arrayName(size){</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">This.length=Size;</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">for(var X=;   
          X&lt;=size;X++)</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">this[X]=0;</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">Reture this;</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">}</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">其中arrayName是定义数组的一个名子,Size是有关数组大小的值(1-size),即数组元素的个数。通过for循环对一个当前对象的数组进行定义,最后返回这个数组。</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">从中可以看出,JavaScript中的数组是从1到size,这与其它0到size的数组表示方法有所不同,当然你可根据需要将数组的下标由1到size调整到0到size-1,可由下列实现:</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">Function arrayName   
          (size)</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">For (var X=0;   
          X&lt;=size;X++)</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">this[X]=0;</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">this.lenght=size;</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">Return this;</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">从上面可以看出该方法是只是调整了this.lenght的位置,该位置是用于存储数组的大小的。从而调整后的数组的下标将与其它语言一致。但请读者注意正是由于数组下标顺序由1到size,使得JavaScript中的对象功能更加强大。</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">b、创建数组实例</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">一个数组定义完成以后,还不能马上使用,必须为该数组创建一个数组实例:</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">Myarray=New   
          arrayName(n);</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">并赋于初值:</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">Myarray[1]=“字串1”;</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">Myarray[2]=“字串2”;</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">Myarray[3]=“字串3”;</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">...</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">Myarray[n]=“字串n”;</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">一旦给数组赋于了初值后,数组中就具有真正意义的数据了,以后就可以在程序设计过程中直接引用。</font></p>  
        <li>  
          <p style="line-height: 150%"><font face="宋体" size="3"><b>创建多维数组</b></font>  
        <li>  
          <p style="line-height: 150%"><font face="宋体" size="3">Function   
          creatMArray(row,col){</font>  
          <p style="line-height: 150%"><font face="宋体" size="3">var indx=0;</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">this.length=(row*10)+col</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">for(var   
          x=1;x&lt;=row;x++)</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">for(var   
          y=1;y&lt;=col;y++)</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">indx=(x*10)+y;</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">this[indx]=””;</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">}</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">myMArray=new   
          creatMArray();</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">之后可通过myMArray[11]、myMArray[12]、myMArray[13]、myMArray[21]、myMArray[22]、myMArray[23]、</font></p>  
          <p style="line-height: 150%"><font face="宋体" size="3">…来引用。</font></p>  
        <li>  
          <p style="line-height: 150%"><font face="宋体" size="3"><b>内部数组</b></font></li>  
      </ol>  
      <!--mstheme--></font> 
      <!--msthemelist--><table border="0" cellpadding="0" cellspacing="0" width="100%">
        <!--msthemelist--><tr>
          <!--msthemelist--><td valign="baseline" width="42"><img src="amaizbu1.gif" width="15" height="15" hspace="13"></td>
          <td valign="top" width="100%"><!--mstheme--><font face="宋体"> 
          <p style="line-height: 150%">  
            <!--mstheme--></font>
            <!--msthemelist--><table border="0" cellpadding="0" cellspacing="0" width="100%">
              <!--msthemelist--><tr>
                <!--msthemelist--><td valign="baseline" width="42"><img src="amaizbu2.gif" width="12" height="12" hspace="15"></td>
                <td valign="top" width="100%"><!--mstheme--><font face="宋体"> 
              <p style="line-height: 150%"><font face="宋体" size="3">在Java中为了方便内部对象的操作,可以使用窗体(Forms)、框架(Frames)、元素(element)、链接(links)和锚(Anchors)数组实现对象的访问。</font><!--mstheme--></font><!--msthemelist--></td>
              </tr>
            <!--msthemelist--></table>
            <!--mstheme--><font face="宋体"> 
          <p style="line-height: 150%"> </p> 
          <p style="line-height: 150%"><font size="3"><font face="System,??"><img src="Bullet3.gif" width="12" height="12"></font><font lang="ZH-CN" face="宋体"> anchors[]:使用《A   
          name=“anchorName“》标识来建立锚的链接。</font></font></p>  
          <p style="line-height: 150%"> </p>  
          <p style="line-height: 150%"><font size="3"><font face="System,??"><img src="Bullet3.gif" width="12" height="12"></font><font lang="ZH-CN" face="宋体"> links[]:   
          使用&lt;A href=”URL”&gt;来定义一个越文本链接项。</font></font></p>  
          <p style="line-height: 150%"> </p>  
          <p style="line-height: 150%"><font size="3"><font face="System,??"><img src="Bullet3.gif" width="12" height="12"></font><font lang="ZH-CN" face="宋体"> Forms[]:   
          在程序中使用多窗体时,建立该数组。</font></font></p>  
          <p style="line-height: 150%"> </p>  
          <p style="line-height: 150%"><font size="3"><font face="System,??"><img src="Bullet3.gif" width="12" height="12"></font><font lang="ZH-CN" face="宋体"> Elements[]:在一个窗口中使用从个元素时,建立该数组。</font></font></p>
          <p style="line-height: 150%"> </p>
          <p style="line-height: 150%"><font size="3"><font face="System,??"><img src="Bullet3.gif" width="12" height="12"></font><font lang="ZH-CN" face="宋体"> Frames[]:建立框架时,使用该数组</font></font></p>
          <p style="line-height: 150%"> </p>
          <p style="line-height: 150%"><font size="3"><font face="System,??"><img src="Bullet3.gif" width="12" height="12"></font><font lang="ZH-CN" face="宋体"> anchors[]用于窗体的访问(它是通过《form   
          name=“form1”》所指定的),link[]用于被链接到的锚点的访问(它是通过《a   
          href=URL》所指定的)。Forms[]反映窗体的属性,而anchors[]反映Web页面中的链接属性。</font></font></p>  
            <!--mstheme--></font><!--msthemelist--></td> 
        </tr> 
      <!--msthemelist--></table> 
      <!--mstheme--><font face="宋体"> 
      <p style="line-height: 150%"><font face="宋体" size="3">有关锚数组的文档:</font></p> 
      <!--mstheme--></font> 
      <pre style="line-height: 150%"><font size="3">&lt;HTML&gt;
&lt;HEAD&gt;
&lt;BODY&gt;
&lt;A NAME=</font><font size="3"><font lang="ZH-CN" face="System,??">”</font><font face="Courier New">MyAnchorsName1</font><font lang="ZH-CN" face="System,??">”</font><font face="Courier New">&gt; </font><font lang="ZH-CN" face="System,??">定义第一个锚名
</font><font face="Courier New">HTML Code
&lt;A NAME=</font><font lang="ZH-CN" face="System,??">”</font><font face="Courier New">MyAnchorsName2</font><font lang="ZH-CN" face="System,??">”</font><font face="Courier New">&gt; </font><font lang="ZH-CN" face="System,??">定义第二个锚名
</font><font face="Courier New">HTML Code 
&lt;A HREF=</font><font lang="ZH-CN" face="System,??">”</font><font face="Courier New">#MyAnchorsName1</font><font lang="ZH-CN" face="System,??">”</font><font face="Courier New">&gt;</font><font lang="ZH-CN" face="System,??">建立锚的链接
</font><font face="Courier New">&lt;A HREF=</font><font lang="ZH-CN" face="System,??">”</font><font face="Courier New">#MyAnchorsName2</font><font lang="ZH-CN" face="System,??">”</font><font face="Courier New">&gt; </font><font lang="ZH-CN" face="System,??">建立锚的链接
…</font><font face="Courier New">. </font></font></pre>
      <!--mstheme--><font face="宋体">
      <p style="line-height: 150%"><font face="宋体" size="3">该文档段建立了两面全锚的链接,可通过Anchors[]访问这些锚。document.Anchors[0]反映第一个锚,而document.Anchors[1]反映第二个锚的有关信息。</font></p>
      <p style="line-height: 150%"><font face="宋体" size="3"> </font></p>
      <p style="line-height: 150%"><b><font face="宋体" size="3">五、范例</font></b></p>
      <p style="line-height: 150%"><font face="宋体" size="3">范例1:一个动态文字滚动的例子。</font></p>

⌨️ 快捷键说明

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