IE 中的 JavaScript 错误

标签 javascript internet-explorer

我需要有关 IE6+ 中出现的错误消息的帮助。 请注意,代码运行良好。

消息:需要对象
线路:38
字符数:4
代码:0
URI:http://localhost/dropbox/panorama/index.php?lang=gr

第 38 行的实际内容如下:

<script type="text/javascript"> 
    $(document).ready(function(){
        slideShow();
    });
</script> 

第 38 行是我调用“slideShow()”函数的地方
另请注意,这些函数存储在外部文件中。

这些是外部文件的内容:

$(function slideShow() {
    //Set the opacity of all images to 0
    $('#gallery li').css({opacity: 0.0});

    //Get the first image and display it (set it to full opacity)
    $('#gallery li:first').css({opacity: 1.0});

    //Call the gallery imgGallery to run the slideshow, 5000: 5 seconds interval
    setInterval('imgGallery()',4000);   
});

$(function imgGallery() {
    //Get the first image
    var current = ($('#gallery li.show')?  $('#gallery li.show') : $('#gallery li:first'));

    //Get next image, if reached last image, start over from the first image
    var next = ((current.next().length) ? (current.next()) : $('#gallery li:first'));


    //Set the fade in effect for the next image
    next.css({opacity: 0.0})
        .addClass('show')
        .animate({opacity: 1.0}, 1000);

    //Hide current image
    current.animate({opacity: 0.0}, 1000)
        .removeClass('show');
});

有什么建议吗?

最佳答案

尝试将 setInterval('imgGallery()',4000); 替换为 setInterval(imgGallery,4000);
如果这不起作用,这应该:
setInterval(function(){imgGallery();},4000)

关于IE 中的 JavaScript 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5594017/

相关文章:

javascript - 在 CasperJS 中拆分测试文件——与它的逻辑作斗争

javascript - 如何使用 javascript 和 css 显示扩展文本

javascript - Material UI 3.9.3 未在 IE 中设置复选框样式

javascript - 如何将 <image> 元素添加到 SVG DOM

javascript - Chrome 在波斯语内容中随机呈现问题

javascript - 在 onunload 事件上通知服务器(XMLHttpRequest?)?

javascript - Internet Explorer 上 Array.from 的替代方案或 polyfill

Firefox、Opera 和 IE 的 CSS 转换?

javascript - 自定义 Angular 滤镜使IE 9+崩溃

javascript - 究竟如何进行这个循环的进步呢? (兼容Internet Explorer 9,时间准确)