阅读:10711回复:20
[求助]怎么才能让firefox在无法显示图片的位置上放上一个小红叉之类的东西
IE读不出图片时有个小红叉,但是firefox读不出来的时候那块地方就是空白,看不出来本来应该有个图片,有没有办法解决一下, 多谢~~:roll:
|
|
1楼#
发布于:2007-03-06 13:38
应该是有显示一个占位符的,用show image扩展可以单独刷新此图片。
|
|
|
2楼#
发布于:2007-03-06 13:38
这个图片好像是出现在载入图像之前的阿,就是刚打开网页还没开始载入的时候出现这个,然后过一会如果图片没载出来这个图标也就没了阿。
![]() 比如这里我引用了一个不存在的图片,用firefox浏览这个网页时这里是空白,IE看就是个红叉。 |
|
3楼#
发布于:2007-03-06 13:38
这要看html文件是怎么写的,fx会根据不同情况显示不同的效果,而不像IE统统是一个红叉叉。主要是根据 <img> 属性中是否有alt,alt是否为空。
<html> <body> <table border=2 cellspacing=10> <tr><td><img src="none.gif" /></td> <td><img src="none.gif" alt="none.gif" /></td> <td><img src="none.gif" alt="" /></td></tr> <tr><td>nothing</td> <td>with alt</td> <td>empty alt</td></tr> </table> </body></html> 上面的小代码分别演示了三种情况,1)无alt, 2)有alt内容, 3)alt内容为空 下面的截图说明了每种情况下fx的显示。1)显示占位图 2)显示alt内容,3)显示空白 |
|
4楼#
发布于:2007-03-06 13:38
那alt里的就是图片载入失败时显示的东西?
如果alt为空的怎么办?我怎么才能知道那里有一张图片。 |
|
5楼#
发布于:2007-03-06 13:38
如果alt为空的怎么办?我怎么才能知道那里有一张图片。 网站设计者的问题吧,ALT那个属性本来就是为无法显示图片的时候准备的。 |
|
6楼#
发布于:2007-03-06 13:38
我一般在网站或者论坛无法看到图片的时候都有显示none.gif的。
在userscript.org找到一个broken image的脚本,不知道行不行。手头目前找不到哪个失效图片来测试,大家试试看。 Forces unloadable images to display as the "broken image" outline, rather than being invisible. 翻译:强制无法载入的图片显示其“broken image”图示,而非不显示任何东西。 http://userscripts.org/scripts/source/7171.user.js // ==UserScript== // @name broken images // @namespace tag:zzedar@gmail.com,2006-01-20:brokenimages // @description show broken image outlines // @include * // ==/UserScript== var allImgs = document.getElementsByTagName("img").wrappedJSObject; for (var i in allImgs) { /*Use getAttribute rather than hasAttribute in order to deal with images that have an empty string for src*/ if (allImgs[i].getAttribute("src")) { allImgs[i].onerror = fix; } } function fix() { if (this.complete) { this.width = Math.max(this.width, 24); this.height = Math.max(this.height, 24); this.style.MozForceBrokenImageIcon = 1; } } |
|
|
7楼#
发布于:2007-03-06 13:38
可以拿我写在上面的那个小 html 代码试验嘛,哈哈,不过我机器上没装GreaseMonkey。
|
|
8楼#
发布于:2007-03-06 13:38
谁再试试看5566给的脚本
我这里没看出效果来。 自己参照着改了个 ChangeLog: 改进了对 img 的 alt 属性为空白字符串的匹配 // ==UserScript== // @name broken images // @namespace https://www.firefox.net.cn/newforum/ // @description show broken image outlines // @include * // ==/UserScript== function xpath(query) { return document.evaluate(query, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); } var allImgs = xpath("//img[@alt]"); var patrn=/^\s*$/; for (var i = 0; i < allImgs.snapshotLength; i++) { thisImg = allImgs.snapshotItem(i); if (patrn.test(thisImg.alt)) { thisImg.removeAttribute('alt'); if (thisImg.complete) { thisImg.width = Math.max(thisImg.width, 24); thisImg.height = Math.max(thisImg.height, 24); thisImg.style.MozForceBrokenImageIcon = 1; } } } ![]() |
|
9楼#
发布于:2007-03-06 13:38
[发现]如果src 失效的 img 指定了长宽(width,height),就肯定有broken图标出现,否则就不会显示。原因是不知道图片大小,就默认为0了?
|
|
10楼#
发布于:2007-03-06 13:38
fx 太按照标准行事了,有时反倒对用户的使用造成不方便。
|
|
11楼#
发布于:2007-03-06 13:38
我的看法是,没有图的地方不显示最好,留个红叉在那里多不自在,除非特殊需要^_^
那个需要的狐狸试试大大们的脚本,把结果发上来^_^ |
|
|
12楼#
发布于:2007-03-06 13:38
那个红叉太难看了……
|
|
13楼#
发布于:2007-03-06 13:38
试了下5566给出的那个js,在本该有图片的地方现在出现了一个图片占位符 ^_^。赞一下,多谢了。调整了一下图标的宽度用来和没载入的图片占位符区分 -.-
另:fiag的那个js用了没效果...... |
|
14楼#
发布于:2007-03-06 13:38
这个问题到底如何解决啊?
|
|
上一页
下一页