推送整个网站数组中的所有图像路径

Push all images paths in an array of a whole website

本文关键字:图像 路径 数组 网站      更新时间:2023-09-26

是否可以获取整个网站中使用的数组中所有图像路径的列表?

var allImages = ['images/path1.jpg','images/path2.jpg','images/path3.png']

如果您只需要在任何给定时间获取页面上的图像,则可以使用 document.images 获取页面上的当前图像,然后映射它们以获取 URL:

Array.prototype.map.call(document.images, function (image) { 
    return image.src;
});