javascript - 在 IE ≤ 8 中更改幻灯片时 Nivo-Slider 消失

标签 javascript internet-explorer-8 cross-browser nivo-slider

我正在测试 slider ,它在 Chrome 和 IE 9+ 中工作,但在早期版本中无法正常工作。

我遇到的问题是,当上一张幻灯片卷起时,会显示一个类似错误的图像(然后 loading.gif 可见)并保持两秒钟以上,直到出现下一张幻灯片。< br/> 我尝试更改动画类型,但问题仍然存在。

我申请了 this回答并没有解决问题。

有什么线索吗?

我在 dev7studios 上发布了同样的问题同样,没有答案。

enter image description here

更新 这是生成图像的方法:

private static MvcHtmlString BuildImageTag(string blobName, object htmlAttributes = null, string name = null)
{
  TagBuilder tag = new TagBuilder("img");

  var src = BlobHelper.GetBlobUri(blobName);

  tag.Attributes.Add("src", src.ToString());
  tag.Attributes.Add("name", name);
  if (htmlAttributes != null)
    tag.MergeAttributes(new RouteValueDictionary(htmlAttributes), true);

  return MvcHtmlString.Create(tag.ToString(TagRenderMode.Normal));
}

我如何更改它以使结束标记分开(如 this 答案中所述)?

更新2

启用 JS 调试后,我看到 nivo slider js 文件中出现调试器中断。

enter image description here

JS中的一行是:

u.attr("src",i.currentImage.attr("src")).show();

我什至不确定它是否相关,但我认为它可能有所帮助。

最佳答案

在您页面的源代码中,我看到:

<img name="ImageFileName" src="https://levelblob.blob.core.windows.net/levelblob/images/slides/b0624213-f3cd-4e0f-b1ae-e5e97429b087.jpg" title=""></img>

这不是 W3C 指定的有效 img 标签:

The tag is empty, which means that it contains attributes only, and has no closing tag.

顺便说一句,alt 属性是标准所必需的,但是,没有浏览器会对此提出异议。

因此,在您的情况下,您应该按如下方式重写所有 img 标签:{img 标签末尾没有“/”,当然也没有“结束标签”

 <img name="ImageFileName" src="..." title="" alt="">

加上仍然来自 W3C 的注释提示:

Tip: It is a good practice to specify both the height and width attributes for an image. If these attributes are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image. The effect will be that the page layout will change during loading (while the images load).

不确定您的问题来自此处,但我确定无效的 html 会导致一些问题。

更新

更新后,我发现您正在使用 (asp) 呈现 html。您应该在函数结束时尝试这样做:

return MvcHtmlString.Create(tag.ToString(TagRenderMode.StartTag));

PS:我无法测试任何 asp 代码。

关于javascript - 在 IE ≤ 8 中更改幻灯片时 Nivo-Slider 消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15154704/

相关文章:

html - 如何仅使用CSS设置<select>下拉列表的样式?

html - 网站布局在 Safari 中不起作用

css - IE8字体问题

html - Respond.min.js 仅适用于 IE 11 的 IE 8 仿真模式

javascript - 在没有单独范围的情况下将 div 添加到另一个 div 中

javascript - 如何解决: [Vue warn]: Error when rendering component on the vue. js 2?

jquery - 使用 IE8 居中并旋转图像 (jQueryRotate)

css - 我的网站有 Firefox 不支持/无法识别的字体

javascript - 无法读取未定义 Jade 的属性 'length'

javascript - 准备要传递到 API 查询的字符串(转义特殊字符)