我可以通过JavaScript获取图像的文件大小和MIME类型(仅限FireFox / Gecko / Mozilla) [英] Can I get an image's file size and mime-type via JavaScript (FireFox/Gecko/Mozilla only)

查看:113
本文介绍了我可以通过JavaScript获取图像的文件大小和MIME类型(仅限FireFox / Gecko / Mozilla)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过JavaScript获取图像的文件大小和MIME类型吗?我正在编写一个脚本来检查文档中的所有图像。我只会在FireFox中运行这个脚本,所以FireFox特有的解决方案(无证/非标准/其他)是完全可以接受的。如果需要,我可以使用jQuery。

解决方案

您可以使 HEAD 请求与XHR这将告诉你的文件大小,只要这些图像在您的域名。


Can I get an image's file size and mime-type via JavaScript. I am writing a script for inspecting all images in a document. I will run the script in FireFox only so a solution specific to FireFox (undocumented/non-standard/otherwise) is perfectly acceptable. I can use jQuery if necessary.

解决方案

You could make a HEAD request with XHR which will tell you the file size, provided these images are on your domain.

这篇关于我可以通过JavaScript获取图像的文件大小和MIME类型(仅限FireFox / Gecko / Mozilla)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆