所有脚本现在都是确保签名位于特定的高度/宽度.我想自动开始测量签名内的图像的文件大小,以便脚本可以自动标记在其签名中包含巨大图像的用户.但是,我似乎找不到一种方法来测量页面上加载的图像的大小.我搜索并找到一个特殊的属性IE(element.fileSize),但我显然不能使用我的Greasemonkey脚本.
有没有办法通过JavaScript查找Firefox中图像的文件大小?
编辑:人们误解了这个问题.论坛本身不主持图片;我们托管人们输入的BBCode作为他们的签名.所以,例如,人们输入:
This is my signature,check out my [url=http://google.com]awesome website[/url]! This image is cool! [img]http://image.gif[/img]
我想通过Greasemonkey能够检查这些图像.我可以编写一个批处理脚本扫描所有这些代码,但我只是想知道是否有一种方法来增加我的当前脚本.
解决方法
另外,检查jGuru How can you check the file size from JavaScript in a form with an input type of file?
你会发现一些重点
Well the answer is very simple,you cannot.
Reason: The browser security does not allow the scripts (Javascript/VBScript) or even applets and ActiveX Controls to read files from the local hard disk. You can only read files if your code is signed by some Certificate Authority (CA). Now the input type “FILE” also does not have the permission to read files. We cannot do anything about that since thats what HTML says. So since it cannot read files,it cannot find the size of the file with which the input tag is associated. Since it cannot find the file size,there is no function exposed by JavaScript/VBScript to return the file size. But if you need to find the file size,say in order to restrict the size of the file uploaded to your web-server. Then you can do so by counting the file contents on the server-side,once the user submits it to the server. Thats what many of the free e-mail providers like www.hotmail.com do.