码迷,mamicode.com
首页 > 其他好文 > 详细

获取文档信息

时间:2017-12-02 19:20:55      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:onclick   har   asc   image   2-2   com   body   input   link   

技术分享图片

 

 

<!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>

获取文档信息

标签:onclick   har   asc   image   2-2   com   body   input   link   

原文地址:http://www.cnblogs.com/wxhhts/p/7954862.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!