///pc/img/blank.gif" width="12" height="8">当前位置:///default.htm" class="under">亿度网络 -> ///pc/index.htm" class="under">网页制作教程 -> JavaScript实例
///pc/homepage/javascript/sample/img/bule.gif" width="207" height="13"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1"> ///pc/homepage/javascript/sample/img/js.gif" width="186" height="20"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">
///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">
    显示页面中的链接 ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">  
    ///pc/homepage/javascript/sample/img/bule1.gif" width="28" height="49">  
效 果 演 示 ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">



  
   
 
源代码如下 ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">



这段程序放在<body>与</body>之间

   
源程序讲解: ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">
  ///pc/homepage/javascript/sample/img/bule1.gif" width="28" height="49">  

function extractlinks()
)
定义一个函数。
{ var links=document.all.tags("A")
声明一个变量,寻找所有带A标签的。
var total=links.length
声明一个变量,值为连接的个数。
var win2=window.open
("","","menubar,scrollbars,toolbar")
声明一个变量,打开一个新窗口。
win2.document.write
<br>"("<font size='2'>一共有
"+total+"个连接</font><br>")
先输出页面上一共有多少个连接。
for (i=0;i<total;i++)
这是一个循环,满足条件,执行以下语句。
{ win2.document.write("<font size='2'>"+links[i].outerHTML+"</font> 输出连接内容。
<input type="button" onClick="extractlinks()"
value="显示所有的连接">
插入一个按钮,单击时,调用extractlinks()函数。

注:此效果只能在IE浏览器中实现。

  ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">  
 

 

网页制作 网页设计 网站建设 网站设计 网站制作 做网站 做网页