javascript手冊-l[5]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 longj 的 blog

  • length reflects the number of links in a document

    methods

  • none.

    event handlers

  • onclick
  • onmouseover

    例子

    example 1. the following example creates a hypertext link to an anchor named javascript_intro.

    <a href="http://dev.csdn.net/article/10/#javascript_intro">introduction to javascript</a>

    example 2. the following example creates a hypertext link to an anchor named numbers in the file doc3.htm in the window window2. if window2 does not exist, it is created.

    <li><a href="http://dev.csdn.net/article/10/tppmsgs/msgs0.htm#16" tppabs="http://www.nease.net/~jim/doc3.htm#numbers" target="window2">numbers</a>

    example 3. the following example takes the user back x entries in the history list:

    <a href="javascript:history.go(-1 * x)">click here</a>

    example 4. the following example creates a hypertext link to a url. a set of radio buttons lets the user choose between three urls. the link's onclick event handler sets the url (the link's href property) based on the selected radio button. the link also has an onmouseover event handler that changes the window's status property. as the example shows, you must return true to set the window.status property in the onmouseover event handler.

    <script> var desthref="'http://www.netscape.com/" </script> <form name="form1"> <b>choose a destination from the following list, then click "click me" below.</b> <br><input type="radio" name="destination" value="netscape" onclick="desthref='http://www.netscape.com/'"> netscape home page <br><input type="radio" name="destination" value="sun" onclick="desthref='http://www.sun.com/'"> sun home page <br><input type="radio" name="destination" value="rfc1867" onclick="desthref='http://www.ics.uci.edu/pub/ietf/htm/rfc1867.txt'"> rfc 1867 <p><a href="http://dev.csdn.net/article/10/" onmouseover="window.status='click this if you dare!'; return true" onclick="this.href=desthref"> <b>click me</b></a> </form>

    example 5: links array. the following example opens the netscape home page in the newwindow window. the linkgetter() function uses the links array to display the value of each of its links.

    newwindow=window.open("http://www.netscape.com") function linkgetter() { msgwindow=window.open("") for (var i = 0; i < newwindow.document.links.length; i++) { msgwindow.document.write(newwindow.document.links[i] + "<br></p> <div class="clear-both"></div> </div> <div class="pages"><a href=20050818223338632.htm target="_self" >首页</a> <a href=20050818223338632_4.htm target="_self">上页</a> <a href=20050818223338632_6.htm target="_self">下页</a> <a href=20050818223338632_9.htm target="_self">尾页</a> <a href=20050818223338632.htm target="_self">[1]</a> <a href=20050818223338632_2.htm target="_self">[2]</a> <a href=20050818223338632_3.htm target="_self">[3]</a> <a href=20050818223338632_4.htm target="_self">[4]</a> <a href=20050818223338632_5.htm target="_self"><strong>[5]</strong></a> <a href=20050818223338632_6.htm target="_self">[6]</a> <a href=20050818223338632_7.htm target="_self">[7]</a> <a href=20050818223338632_8.htm target="_self">[8]</a> <a href=20050818223338632_9.htm target="_self">[9]</a> </div> <div class="keywords"> <strong>本文关键:</strong>javascript </div> <div class="ad_doc_ad_2"> <script type="text/javascript"><!-- google_ad_client = "pub-1022332794981269"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text_image"; //2007-03-23: 方案站728x90 google_ad_channel = "2351411502"; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "3D81EE"; google_color_text = "4C4C4C"; google_color_url = "6C82B5"; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> <div class="clear-both"></div> </div> </div> <div id="content_right"> <div class="cbox" id="relate_doc"> <div class="darkboxTitle"><span>  相关方案</span></div> <div class="ad_site_index_right_1"> <!-- SiteSearch Google --> <form method="get" action="http://www.google.cn/custom" target="google_window"> <table border="0" bgcolor="#ffffff"> <tr><td nowrap="nowrap" valign="top" align="left" height="32"> <a href="http://www.google.com/"> <img src="http://www.google.com/logos/Logo_25wht.gif" border="0" alt="Google" align="middle"></img></a> <br/> <input type="hidden" name="domains" value="www.cn-doc.com"></input> <label for="sbi" style="display: none">输入您的搜索字词</label> <input type="text" name="q" size="15" maxlength="255" value="" id="sbi"></input> <label for="sbb" style="display: none">提交搜索表单</label> <input type="submit" name="sa" value="搜索" id="sbb"></input> </td></tr> <tr> <td nowrap="nowrap"> <table> <tr> <td> <input type="radio" name="sitesearch" value="" id="ss0"></input> <label for="ss0" title="搜索网络"><font size="-1" color="#000000">Web</font></label></td> <td> <input type="radio" name="sitesearch" value="www.cn-doc.com" checked id="ss1"></input> <label for="ss1" title="搜索 www.cn-doc.com"><font size="-1" color="#000000">www.cn-doc.com</font></label></td> </tr> </table> <input type="hidden" name="client" value="pub-1022332794981269"></input> <input type="hidden" name="forid" value="1"></input> <input type="hidden" name="channel" value="9722277709"></input> <input type="hidden" name="ie" value="GB2312"></input> <input type="hidden" name="oe" value="GB2312"></input> <input type="hidden" name="flav" value="0000"></input> <input type="hidden" name="sig" value="Dl1iwOxBnXTtaDIa"></input> <input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;LH:50;LW:200;L:http://www.cn-doc.com/images/forgoogle.gif;S:http://www.cn-doc.com;FORID:1"></input> <input type="hidden" name="hl" value="zh-CN"></input> </td></tr></table> </form> <!-- SiteSearch Google --> </div> <ul class="darklist"> <li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223338111.htm" title="图档结构树的设计与关联" target="_blank">图档结构树的设计与关联</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223338432.htm" title="评“面向对象的JavaScript编程”一文" target="_blank">评“面向对象的JavaScri</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223338299.htm" title="OOP In JS [JS脚本中的面向对象]" target="_blank">OOP In JS [JS脚本</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223339985.htm" title="在Javascript中为String对象添加trim,ltrim,rtrim方法" target="_blank">在Javascript中为St</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223339414.htm" title="排序Select中Option项的一个示例" target="_blank">排序Select中Option</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223339328.htm" title="将人民币数字转换成大写形式" target="_blank">将人民币数字转换成大写形式</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223339747.htm" title="对象化JS之----日期选择" target="_blank">对象化JS之----日期选择</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223339652.htm" title="JavaScript 寫時鍾日曆" target="_blank">JavaScript 寫時鍾日</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223339981.htm" title="扫雷" target="_blank">扫雷</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223339498.htm" title="怎样捕捉 Delete 键" target="_blank">怎样捕捉 Delete 键</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223337711.htm" title="Java、Java Applet与 JavaScript间的通信" target="_blank">Java、Java Apple</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/2005081822333748.htm" title="怎样用Javascript获得IE临时目录" target="_blank">怎样用Javascript获得</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223337507.htm" title="类似ListView ,htc组件" target="_blank">类似ListView ,htc</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223337890.htm" title="Select的OnChange()事件" target="_blank">Select的OnChange</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223336799.htm" title="对象化JS之----文件上传客户端控制脚本" target="_blank">对象化JS之----文件上传客</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/200508182233365.htm" title="CSDN无限级树数据库版(ASP+ACCESS)" target="_blank">CSDN无限级树数据库版(AS</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223336841.htm" title="JSP" target="_blank">JSP</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223336384.htm" title="如何使用可以接受输入的列表框" target="_blank">如何使用可以接受输入的列表框</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223336485.htm" title="双向链表&amp;&amp;堆栈" target="_blank">双向链表&amp;&amp;堆</a>…</li><li><a href="../../_soft_javascript_tech_doc/2005_08_18_22/20050818223336805.htm" title="Javascript实现网页上的多级菜单" target="_blank">Javascript实现网页上</a>…</li> </ul> <div class="ad_site_index_right_2"> <script type="text/javascript"><!-- google_ad_client = "pub-1022332794981269"; google_ad_width = 180; google_ad_height = 60; google_ad_format = "180x60_as_rimg"; google_cpa_choice = "CAAQ0cX8zwEaCEpGRZ0Cl8yyKPu_93M"; google_ad_channel = "6903800490"; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> </div> </div> <div class="clear-both">&nbsp;</div> <div id="ContentBottom" class="darkBox"> <p>本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)</p><a href="#"><img src="../../images/btn_top.gif" width="51" height="11" alt="go top"/></a> </div> </div> </div> <script type="text/javascript" language="javascript" src="../../comm/doc/w3c_99_bottom.js"></script> <script type="text/javascript" language="javascript" src="../../comm/clicksum_doc.asp?typeid=46&infoid=390031"></script> <script type="text/javascript" language="JavaScript" src="../../comm/statistics.js"></script> </body> </html>