小白教程
所有教程
关于
Search
172.69.59.47
172.69.59.47
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Coll doc links”的源代码
本页内容
上一节:
Prop_doc_lastmodified
下一节:
Met_document_normalize
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:document.links}}[[Category:dom obj document|30]] = HTML DOM links 集合 = [[dom obj document|Document 对象]] == 定义和用法 == links 集合返回当前文档所有链接的数组。 '''提示:''' links 集合计算 <a href=""> 标签和 <area> 标签。 == 语法 == <pre> document.links[].property </pre> == 浏览器支持 == 所有主要浏览器都支持 links 集合 == 实例 1 == 返回文档的链接数: <sample title="" desc="" lang="html" hererun="1"> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> </head> <body> <img src ="planets.gif" width="145" height="126" alt="Planets" usemap ="#planetmap"> <map name="planetmap"> <area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun"> <area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury"> <area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus"> </map> <p><a href="/js/">JavaScript 教程</a></p> <p>链接/地址数目: <script> document.write(document.links.length); </script></p> </body> </html> </sample> 以上实例输出结果: <sample title="" desc="" lang="html" hererun="1"> 链接/地址数目: 4 </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> </head> <body> <img src ="planets.gif" width="145" height="126" alt="Planets" usemap ="#planetmap"> <map name="planetmap"> <area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun"> <area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury"> <area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus"> </map> <p><a href="/js/">JavaScript 教程</a></p> <p>链接/地址数目: <script> document.write(document.links.length); </script></p> </body> </html> </run> == 实例 2 == 返回文档的第一个链接: <sample title="" desc="" lang="html" hererun="1"> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> </head> <body> <img src ="planets.gif" width="145" height="126" alt="Planets" usemap ="#planetmap"> <map name="planetmap"> <area id="sun" shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun"> <area id="mercury" shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury"> <area id="venus" shape="circle" coords="124,58,8" href="venus.htm" alt="Venus"> </map> <p><a id="javascript" href="/js/">JavaScript 教程</a></p> <p>第一个链接/地址的ID: <script> document.write(document.links[0].id); </script></p> </body> </html> </sample> 以上实例输出结果: <sample title="" desc="" lang="html" hererun="1"> 第一个链接/地址的ID:sun </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> </head> <body> <img src ="planets.gif" width="145" height="126" alt="Planets" usemap ="#planetmap"> <map name="planetmap"> <area id="sun" shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun"> <area id="mercury" shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury"> <area id="venus" shape="circle" coords="124,58,8" href="venus.htm" alt="Venus"> </map> <p><a id="javascript" href="/js/">JavaScript 教程</a></p> <p>第一个链接/地址的ID: <script> document.write(document.links[0].id); </script></p> </body> </html> </run> [[dom obj document|Document 对象]]
返回至“
Coll doc links
”。
上一节:
Prop_doc_lastmodified
下一节:
Met_document_normalize