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

📄 showlink.htm

📁 简单的讲解语言,非常实用,使你在短期内就能熟练掌握其变成技巧
💻 HTM
字号:
<html>
<head>
<title>洪恩在线 - Javascript实例</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="../homepage.css">

</head>

<body bgcolor="#FFFFFF" ><script language="Javascript" src="/pub/js/head.js"></script>
<table width="760" height="20" border=0 cellspacing="0" cellpadding="0" align="center" >
  <tr bgcolor="CFDFFF"> 
    <td height=20 class="p1" align="left"><img src="/pc/img/blank.gif" width="12" height="8"><font color="#000000"><font color="#FF9966">当前位置</font>:<a href="/default.htm" class="under">洪恩在线</a> 
      -&gt; <a href="/pc/index.htm" class="under">电脑乐园</a> -&gt; JavaScript实例</font></td>
  </tr>
</table> 
 <script language="JavaScript">
if(document.layers)
{
   alert("此效果在Netscape浏览器中不能实现!");
}
<!--
function extractlinks(){
var links=document.all.tags("A")
var total=links.length
var win2=window.open("","","menubar,scrollbars,toolbar")
win2.document.write("<font size='2'>一共有"+total+"个连接</font><br>")
for (i=0;i<total;i++){
win2.document.write("<font size='2'>"+links[i].outerHTML+"</font><br>")
}
}
//-->
</script>   
<table width="760" border=0 cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td width="207" valign="top"><img src="img/bule.gif" width="207" height="13"></td>
    <td bgcolor="A8A8AB" width="1"><img src="img/blank.gif" width="1" height="1"></td>
    <td align="right" height="22" width=530><img src="img/js.gif" width="186" height="20"></td>
    <td width="22"><img src="img/blank.gif" width="1" height="1"></td>
  </tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td width="124"><img src="img/blank.gif" width="1" height="1"></td>
    <td background="img/line.gif" height="27" width=636><img src="img/blank.gif" width="1" height="1"></td>
  </tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td class=p3 align="center" width=711><b>    显示页面中的链接</b></td>
    <td class="p2" width="1" bgcolor="A8A8AB"><img src="img/blank.gif" width="1" height="1"></td>
    <td class="p2" width="48">&nbsp;</td>
  </tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td align="center" valign="top">&nbsp;</td>
    <td>&nbsp;</td>
    <td bgcolor="5F74BF" width="28" align="center"><img src="img/bule1.gif" width="28" height="49"></td>
    <td width="37" align="center">&nbsp;</td>
  </tr>
  <tr> 
    <td align="center" valign="top"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr align="center"> 
          <td> 
            <table width="110" border="0" cellspacing="0" cellpadding="0">
              <tr bgcolor="5F74BF" align="center"> 
                <td class="p1" align="right"><b><font color="#FFFFFF">效 果 演 示</font></b><font color="#FFFFFF">:</font></td>
                <td class="p1" width="11"><img src="img/bule2.gif" width="11" height="18"></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <td class=p2 align="left" > <br>
      <form>
        <br>
        <input type="button" onClick="extractlinks()" value="显示所有的连接" name="button">
      </form>
      <b><font color="#FF3333"><br>
        </font></b> </td>
    <td bgcolor="5F74BF" width="28" align="center">&nbsp;</td>
    <td width="37" align="center">&nbsp;</td>
  </tr>
  <tr> 
    <td align="center" valign="top"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td height="15">&nbsp;</td>
        </tr>
        <tr align="center"> 
          <td> 
            <table width="110" border="0" cellspacing="0" cellpadding="0">
              <tr bgcolor="5F74BF" align="center"> 
                <td class="p1" align="right"><b><font color="#FFFFFF">源代码如下</font></b><font color="#FFFFFF">:</font></td>
                <td class="p1" width="11"><img src="img/bule2.gif" width="11" height="18"></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <td width="457" class="p2" valign="top"><b><br>
      <br>
      </b><span class="p1"><font color="#6633FF"> </font></span><b><br>
      </b>
      <form>
        <p><span class="p1"><font color="#6633FF">这段程序放在&lt;body&gt;与&lt;/body&gt;之间</font></span> 
          <textarea name="textarea3" onFocus="this.select()" onMouseOver="this.focus()" cols="50" rows="13" wrap="VIRTUAL" style="BACKGROUND-COLOR: #D5E9FD;" >&lt;script language=&quot;JavaScript1.2&quot;&gt;
&lt;!--
function extractlinks(){
var links=document.all.tags(&quot;A&quot;)
var total=links.length
var win2=window.open(&quot;&quot;,&quot;&quot;,&quot;menubar,scrollbars,toolbar&quot;)
win2.document.write(&quot;&lt;font size='2'&gt;一共有&quot;+total+&quot;个连接&lt;/font&gt;&lt;br&gt;&quot;)
for (i=0;i&lt;total;i++){
win2.document.write(&quot;&lt;font size='2'&gt;&quot;+links[i].outerHTML+&quot;&lt;/font&gt;&lt;br&gt;&quot;)
}
}
//--&gt;
&lt;/script&gt; 
&lt;form&gt;
&lt;input type=&quot;button&quot; onClick=&quot;extractlinks()&quot; value=&quot;显示所有的连接&quot;&gt;
&lt;/form&gt;</textarea>
        </p>
      </form>
      <b> </b></td>
    <td bgcolor="5F74BF" width="28" align="center">&nbsp;</td>
    <td width="37" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td align="center" valign="bottom" height="36"> 
      <table width="238" border="0" cellspacing="0" cellpadding="0">
        <tr align="center"> 
          <td> 
            <table width="110" border="0" cellspacing="0" cellpadding="0">
              <tr bgcolor="5F74BF" align="center"> 
                <td class="p1" align="right"><b><font color="#FFFFFF">源程序讲解:</font></b></td>
                <td class="p1" width="11"><img src="img/bule2.gif" width="11" height="18"></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
    <td width="457" class="p2" valign="top" height="36">&nbsp;</td>
    <td bgcolor="5F74BF" width="28" align="center" height="36"><img src="img/bule1.gif" width="28" height="49"></td>
    <td width="37" align="center" height="36">&nbsp;</td>
  </tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td class="p2" align="right" width="693"> <br>
      <table width="650" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td>
            <table width="100%" border="1" cellspacing="1" cellpadding="1" bordercolorlight="#666666" bordercolordark="#666666" class=p2>
              <tr> 
                <td width="45%">function extractlinks()<br>
                  )</td>
                <td width="55%">定义一个函数。</td>
              </tr>
              <tr bgcolor="CFDFFF"> 
                <td width="45%">{ var links=document.all.tags(&quot;A&quot;)<br>
                </td>
                <td width="55%">声明一个变量,寻找所有带A标签的。</td>
              </tr>
              <tr> 
                <td width="45%">var total=links.length <br>
                </td>
                <td width="55%">声明一个变量,值为连接的个数。</td>
              </tr>
              <tr bgcolor="CFDFFF"> 
                <td width="45%">var win2=window.open<br>
                  (&quot;&quot;,&quot;&quot;,&quot;menubar,scrollbars,toolbar&quot;) 
                  <br>
                </td>
                <td width="55%">声明一个变量,打开一个新窗口。</td>
              </tr>
              <tr> 
                <td width="45%">win2.document.write<br>
                  &lt;br&gt;&quot;(&quot;&lt;font size='2'&gt;一共有<br>
                  &quot;+total+&quot;个连接&lt;/font&gt;&lt;br&gt;&quot;) <br>
                </td>
                <td width="55%">先输出页面上一共有多少个连接。</td>
              </tr>
              <tr bgcolor="CFDFFF"> 
                <td width="45%">for (i=0;i&lt;total;i++)<br>
                </td>
                <td width="55%">这是一个循环,满足条件,执行以下语句。</td>
              </tr>
              <tr> 
                <td width="45%">{ win2.document.write(&quot;&lt;font size='2'&gt;&quot;+links[i].outerHTML+&quot;&lt;/font&gt;</td>
                <td width="55%">输出连接内容。</td>
              </tr>
              <tr bgcolor="CFDFFF"> 
                <td width="45%">&lt;input type=&quot;button&quot; onClick=&quot;extractlinks()&quot; 
                  <br>
                  value=&quot;显示所有的连接&quot;&gt;</td>
                <td width="55%">插入一个按钮,单击时,调用extractlinks()函数。</td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      <br>
      <table width="640" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td><span class="p1"><font color="#6633FF">注:此效果只能在IE浏览器中实现。</font></span><b></b></td>
        </tr>
      </table>
      <br>
    </td>
    <td class="p2" width="18">&nbsp;</td>
    <td class="p2" width="1" bgcolor="A8A8AB"><img src="img/blank.gif" width="1" height="1"></td>
    <td class="p2" width="48">&nbsp;</td>
  </tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr bgcolor="5F74BF"> 
    <td>&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>

⌨️ 快捷键说明

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