zoukankan      html  css  js  c++  java
  • 获取文档信息

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>获取文档信息</title>
    </head>
    <script type="text/javascript">
    function getDocument(){
    var imgNum=document.images.length;//获取图片数量
    var linkNum=document.links.length;//获取链接数量
    var anchorNum=document.anchors.length;//统计所有锚数量

    var documentInfo="";
    documentInfo+="文档中所有图片数量"+imgNum +"<br/>";
    documentInfo+="文档中所有链接数量"+linkNum+"<br/>";
    documentInfo+="文档中锚数量"+anchorNum+"<br/>";
    documentInfo+="文档标题"+document.title+"<br/>";//获取文档标题
    documentInfo+="文档域名"+document.domain+"<br/>";//获取文档域名
    documentInfo+="文档URL"+document.URL+"<br/>";//获取文档URL
    document.getElementById("docInfo").innerHTML=documentInfo;//显示文档内容

    }
    </script>
    <body>
    <a href="https://www.baidu.com/" name="baiduAnchor">
    <img src="img/baidu.png" /></a>
    <a href="https://www.so.com/ "name="360Anchor">
    <img src="img/360.png" /></a>
    <a href="https://www.sogou.com/" name="sougouAnchor">
    <img src="img/sougou.png" /></a><br />

    <input type="button" value="获取文档信息" onclick="getDocument()"/>

    <div id="docInfo"></div>
    </body>
    </html>

  • 相关阅读:
    协程初探
    属性传值
    分析代理模式
    上下文菜单与TrackPopupMenu
    走进小作坊(十六)----口碑营销
    线程池QueueUserWorkItem
    exosip
    Spark Core源代码分析: Spark任务运行模型
    微软2014校园招聘笔试试题
    怎样配置Tomcat环境变量
  • 原文地址:https://www.cnblogs.com/wxhhts/p/7954862.html
Copyright © 2011-2022 走看看