- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
插件
我正在使用名为 lazyload 的 jQuery 插件.
它的作用是lazy
加载图像 - 这意味着它不会在浏览器中渲染它们,直到图像位于视口(viewport)范围内。
例如,当您的页面包含许多图像,并且您不希望它永远花费在初始加载上时,这非常有用。
火狐
好的,所以我也在使用 Firefox
版本23.0.1
问题
这个插件很棒,但是当在一些图像后向下滚动时,我开始收到图像无法加载的错误(只有一个用于损坏图像链接的通用占位符),并且在控制台中它记录:
Image corrupt or truncated: [image url]
并不是图像有问题。它们单独渲染都很好。
它不是在特定图像上,因为它是随机的。如果我再次加载页面,图像将是 corrupt
现在可以加载,其他图像返回损坏的链接并记录 corrupt
在控制台中。
我四处寻找这个,似乎同时获取 <img>
存在一些问题。 src 标签。
可能应该在获取时设置延迟,但是您不能总是知道延迟应该是多长时间。如果一个图像比另一个图像大,它仍然可能发生冲突(具有静态延迟时间,而不是 complete
回调)。
因此,我想请求:
a) 如果有人知道解决方案(例如捕获错误发生时并重新触发加载图像功能)
b) 如果有人可以提出 $.extend()
到上面的库(lazyload),它将创建一个回调函数并等待,直到所有事件的提取都是 complete
在加载下一个之前(如果这是问题 - 我不确定是否是)我不是 jQuery 忍者,所以我对代码有点迷失。我可以弄清楚,但它可能会很脏......
c)如果这不是问题,那么我将不胜感激,告诉我如何解决这个问题
最佳答案
正如建议的那样answer对于与您类似的问题:
It appears that when changing the src attribute of the img tag, Firefox fires a load event. This is contrary to the HTML5 specification, which says that if the src attribute is changed, then any other fetch already in progress should be ended (which Firefox does), and no events should be sent. The load event should be sent only if the fetch was completed successfully. So I'd say that the fact that you get a load event is a Firefox bug.
然后:
The best option may be to create a new element each time you wish to change the src attribute.
这是有道理的。在 lazyload
代码中,您会发现这一部分,似乎是在图像加载时响应触发 appear
的滚动事件:
/* When appear is triggered load original image. */
$self.one("appear", function() {
if (!this.loaded) {
if (settings.appear) {
var elements_left = elements.length;
settings.appear.call(self, elements_left, settings);
}
$("<img />")
.bind("load", function() {
var original = $self.attr("data-" + settings.data_attribute);
$self.hide();
if ($self.is("img")) {
$self.attr("src", original);
} else {
$self.css("background-image", "url('" + original + "')");
}
$self[settings.effect](settings.effect_speed);
self.loaded = true;
您可以放置一个 AND 运算符,后跟一些标志或函数返回,以验证最后一个图像是否已完全加载到该部分:
if ($self.is("img") && lastImageIsLoadde() === true) { /*pseudocode here*/
从而防止 img src
在正确时间之前被替换(因为 settings.placeholder
是脚本用来代替即将加载的图像的图像滚动时)并看看它是否适合您。
关于jquery - 火狐浏览器中如何处理 "image corrupt or truncated",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32459621/
如何从 中删除选定的附件元素 ? 当您已经选择一个附件时,Firefox 似乎无法删除附件。 我尝试删除名称并点击打开,但没有任何反应。 我也试过取消,但附件还在。 我的解决方案是添加一些 oncl
我在 Firefox(版本 38.05)中遇到一个非常奇怪的错误。我有一个如下所示的表单,以及一段用于验证的 Javascript Javascript function ch
所以我知道how to使用 CSS 指定 HTML input 占位符的颜色。然而,这似乎不适用于 Mozilla Firefox 中 number 类型的 input 字段(尽管在 Chrome 中
我创建了简单的类似 hello world 的插件,它绘制了红色框。 嵌入 xulrunner 应用程序后,该插件几乎可以正常工作。 Xulrunner 应用程序在调整应用程序窗口大小时成功重绘了框。
我在 Firefox javascript 中遇到了一件非常奇怪的事情。我创建了一个对象,并使用字符串作为键。当我看到“watch”键是否有值时,如果其中没有“watch”键,它会通过返回 Objec
好的。我知道我问的是一个老生常谈的问题,但我发布这个问题是因为尽管尝试了各种链接上提供的所有解决方案,我的问题仍未得到解决。 我的限制 - 我不想使用已保存的 Firefox 配置文件来保存网站的证书
我只是想知道如何通过浏览器(Firefox)调用 WCF 服务? 我的 WCF 服务如下所示: http://localhost:4249/TestService.svc 我试过这个: [Servic
想要一些帮助来解释为什么这不起作用 from selenium import webdriver browser = webdriver.Firefox() browser.get('https://
Firefox 是一种浏览器,没有它我什至无法想到开发 Web 应用程序。它带有许多方便的附加组件和功能,使开发人员的工作变得轻松。 然而,Firefox 的功能非常庞大,并不是每个人都知道它们。因此
我的吉普车有一个基于浏览器的服务手册。在 IE 中运行良好,但在 Firefox 中运行不佳。基本上有一个目录,您可以展开并深入到子主题,例如 [+] 手拿包 [+] 冷却 [+] 电气 但是 Fir
看了一下,发现了一些东西,但似乎没有什么能像我想要的那样工作。 最初我有我的解决方案与 internet explorer 和 chrome 一起工作,但不是 firefox(这让我不满意不能工作)
编辑我有一个状态栏,可用于启用和禁用插件。 最佳答案 定义时: 您的弹出窗口由两个元素组成,image 和 menuitem。弹出窗口
我在菜单中定位悬停效果时遇到问题。在 Firefox 中没问题,但在 chrome 中悬停效果是 UP 的问题。 Firefox:(这里可以) http://pasteboard.co/1ami0qr
这个问题在这里已经有了答案: †appearing instead of quotation marks (1 个回答) 关闭 5 年前。
我的 ASP.net 网站中的一个 GridView header 有问题。我想在我的标题单元格中显示绿色背景颜色的白色文本。我还想让这些单元格的边框颜色保持黑色。 这是我用于标题的 CSS: .my
我有这个输入,在 :before 标签中定义了一些内容。在 IE 和 Chrome 中它运行完美,但 Firefox 把它弄得一团糟。 内容应该在输入标签中可见,但在 Firefox 中,内容在 in
谁能告诉我为什么 firefox 没有打开并添加了以下 Net::HTTPServer 行? #!/usr/bin/perl # v5.10.1 / linux use strict; use war
我和我的同事在使用 Firefox 3.0.6 访问我们正在开发的 Java 1.6.0___11 Web 应用程序时遇到问题。 session 开始后 1 到 30 分钟内一切正常...但最终,连接
friend , 我注意到在 Firefox v23.0.1 中,HTMLElement(input,button..etc) 的 hasOwnProperty 不起作用, button1.hasOw
有什么办法可以禁用这个“功能”吗? 例如,如果向 http://localhost/foo.html 发出请求,并且我已将其指定为根地址“301”,则所有后续请求都会发送到 foo.html。 htm
我是一名优秀的程序员,十分优秀!