【问题标题】:IE8/9 slide show visibility issues..?IE8/9 幻灯片放映可见性问题..?
【发布时间】:2013-04-20 17:23:00
【问题描述】:

js 和 jquery newb 在这里,我在http://www.irvins.com:8080 的主页上的幻灯片有问题 - 我已经让它在 IE10/Firefox/Webkit 中工作,但 IE8 和 IE9 仍然无法与我的脚本。 IE8 不会显示初始幻灯片,也不会设置动画(因此您只会得到一个空白区域,各种幻灯片都标记为“显示:无”。IE9 拾取第一张幻灯片,但再次没有动画。这是脚本我正在使用 jquery 1.8.1 (min) 和以下脚本:

components.directive('uiSlideshow', function () {
    return {
        restrict: 'EAC',
        link: function(scope, elm, attr, ctrl) {
            console.log(elm);
            elm.children('.slide').first().addClass('active');
            setInterval(function() { 
                elm.children('.slide')
                    .first()
                    .fadeOut(1000)
                    .next()
                    .fadeIn(1000)
                    .end()
                    .appendTo(elm);
            },  5000);
        }
    }
});

幻灯片(来自 Chrome - IE8 的所有幻灯片都显示为“display: none;”):

<section class="feature ui-slideshow"> 
    <figure class="slide" style="display: block;">
        <a href="/search_results.asp?category=25&amp;top_category_id=25">
            <img src="public/images/ss-lighting-0213.jpg" alt="Country Style Lighting" border="0">
        </a>
    </figure>
    <figure class="slide" style="display: none;">
        <a href="/search_results.asp?category=70&amp;top_category_id=70">
            <img src="public/images/ss-tinware-0213.jpg" alt="Tinware" border="0">
        </a>
    </figure>
    <figure class="slide" style="display: none;">
        <a href="/search_results.asp?category=55&amp;top_category_id=55">
            <img src="public/images/ss-furniture-0213.jpg" alt="Upholstered Furniture" border="0">
        </a>
    </figure>
    <figure class="slide active" style="display: none;">
        <a href="/search_results.asp?category=60&amp;top_category_id=60">
            <img src="public/images/ss-bedding-0213.jpg" alt="Milsboro Quilted Bedding" border="0">
        </a>
    </figure>
</section>

我忽略了什么明显的东西?我正在使用旧 IE 无法理解的特定内容?

---------------------- 更新 -------------------- ---

感谢 ajp15243 提出的 IE9 修复建议

我现在意识到我有两个完全不同的问题,一个控制台变量问题(已解决,请参阅下面的 cmets)和其他阻止 IE8 显示任何内容的问题,我认为这一定是我的“指令”的另一部分。 js的代码?

在我的 js 文件开头为滑块添加以下内容后,IE9 幻灯片现在可以动画了:

/**
 * Protect window.console method calls, e.g. console is not defined on IE
 * unless dev tools are open, and IE doesn't define console.debug
 */
(function() {
  if (!window.console) {
    window.console = {};
  }
  // union of Chrome, FF, IE, and Safari console methods
  var m = [
    "log", "info", "warn", "error", "debug", "trace", "dir", "group",
    "groupCollapsed", "groupEnd", "time", "timeEnd", "profile", "profileEnd",
    "dirxml", "assert", "count", "markTimeline", "timeStamp", "clear"
  ];
  // define undefined methods as noops to prevent errors
  for (var i = 0; i < m.length; i++) {
    if (!window.console[m[i]]) {
      window.console[m[i]] = function() {};
    }    
  } 
})();

---------------------- 更新 2 ------------------- ----

问题解决了!

第二个问题原来与 angular.js 有关,它需要更改我一直用于“html 类...”的内容,见下文:

<!--[if IE 8 ]><html lang="en" class="ng-app:Irvins" id="ng-app" ng-app="Irvins" xmlns:ng="http://angularjs.org"> <![endif]-->

【问题讨论】:

    标签: javascript jquery internet-explorer slide


    【解决方案1】:

    您的代码包括console.log(elm);。这将适用于 Firefox 和 Chrome,因为这些浏览器已经很好地定义了 console 变量。但是,在 IE 中存在一些怪癖(说得好),并且您的脚本可能会在该行引发错误,并且不会在 IE8/9 中继续。在 IE8 中使用 this question,在 IE9 中使用 this question

    当您准备好让网站“上线”时,最好也删除所有控制台日志记录。

    【讨论】:

    • 谢谢!您对控制台的看法是正确的-似乎必须在 IE8/9 中打开“F12”/开发人员工具栏才能使控制台变量工作(奇怪...) IE9 现在按预期工作,但是 IE8 仍然没有显示任何内容,所有幻灯片都是“显示:无;”。可能是我在某处使用的名称仍在浏览器中跳闸?
    • “Bizarre”甚至没有开始描述 IE8 中的调试/开发工具:)。
    • 哈哈,我想了解一下 IE 开发者在这些“功能”背后的想法,他们在 beta 中一定注意到了这样的事情 sigh 抱歉半评论更多。没有足够的字符...我将编辑我的原始帖子以反映 IE9 修复。
    • 我会先看看 IE8 开发者工具控制台是否在任何地方吐出错误。记得点击“开始调试”!
    • 经过一番挫折,一切都解决了! 请参阅上面的编辑 - 原来主要问题是由 angular.js 引起的,我没有意识到 IE8 正在处理“ html class="ng-app"... 不同。解决方案是:&lt;!--[if IE 8 ]&gt;&lt;html lang="en" class="ng-app:Irvins" id="ng-app" ng-app="Irvins" xmlns:ng="http://angularjs.org"&gt; &lt;![endif]--&gt; 有关此 IE8 angular.js 怪癖的更多信息,请访问此链接:stackoverflow.com/questions/13184063/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多