document.images 应用

一个脚本,获取document的所有图形。

// JavaScript Document
<h1>darg this tool</h1>
<a href="javascript:
var x='';
for(var i=0;i<document.images.length;i++)
{
    x+='<img src='+document.images[i].src+'  /><br/>'; 
}
if(x!='')
{
    document.write('<center>'+x+'</center>');
    void(document.close());
}
else
{
    alert('no images!');
} 
">no images own</a>
<br/>
<img src="http://localhost/css/images/myzi.png"  />
<p style="background:url('http://localhost/css/images/yanzi.png'); 500px; height:300px;">
<pre>
hell world
</pre>
</p>

images of type HTMLCollection, readonlyA collection of all the IMG elements in a document. The behavior is limited to IMG elements for backwards compatibility. w3org

问题就出现了,images就返回元素为img的图形,网站通过css定义的 图片如:

background:url('xxx.jpg');

无法获取。

怎么获取所有的图片,google下,没有什么好的solution。

http://topic.csdn.net/u/20120406/07/f32cf55f-729b-4088-8692-609bd9a1c745.html

原文地址:https://www.cnblogs.com/youxin/p/2669402.html