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>

  • 相关阅读:
    Jquery easyui中的有效性检查
    当执行批量删除时
    nested exception is com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1044 > 1024
    java的四种取整方法
    springmvc乱码解决
    跨域
    垂直居中
    js判断数组
    安装 node-sass 的正确姿势
    js判断qq浏览器
  • 原文地址:https://www.cnblogs.com/wxhhts/p/7954862.html
Copyright © 2011-2022 走看看