简体   繁体   English

jQuery在IE8中不起作用?

[英]jQuery doesn't work in IE8?

I am working on a site here: mfm.treethink.net All the jquery works fine in Firefox, Chrome and Safari but on IE8 it gives me errors and the banner at the top doesn't work (which uses the crossSlide jQuery plugin) and as well the image rollovers don't work with the colour change. 我在这里的网站上工作: mfm.treethink.net所有的jquery在Firefox,Chrome和Safari中运行良好但在IE8上它给我带来了错误,顶部的横幅不起作用(使用了crossSlide jQuery插件)以及图像翻转不适用于颜色变化。

IE8 is telling me that the errors are on lines 53, 134 and 149 in the source, all of those lines are where the jquery function is declared. IE8告诉我错误在源代码的第53,134和149行,所有这些行都是声明jquery函数的地方。

$(document).ready(function(){

I am running jquery 1.4. 我正在运行jquery 1.4。 Oddly enough, the other piece of jQuery I have on that page works, the artist browse/select menu on the right. 奇怪的是,我在该页面上的另一个jQuery工作,右边是艺术家浏览/选择菜单。 But the banner and image rollovers don't. 但横幅和图像翻转没有。

Here are all the scripts I'm running: 以下是我正在运行的所有脚本:

1: the banner - doesn't work in IE8 1:横幅 - 在IE8中不起作用

<script type="text/javascript">
  $(function() {
    $('#banner').crossSlide({
      sleep: 5,
      fade: 1
    }, [
      <?php
   $pages = get_posts('numberposts=2000&post_type=artist&post_status=publish');

   $i = 1;
   foreach( $pages as $page ) {
       $content = $page->post_title;
       if( empty($content) ) continue;

       $content = apply_filters('the_content', $content);

       ?>

       { src: '/wp-content/uploads/<?php echo $page->post_name ?>.jpg' },

<?php $i++;

   }    ?>
    ]);
  });

</script>

2 - image rollovers - doesn't work in IE8 2 - 图像翻转 - 在IE8中不起作用

<script type="text/javascript">

$(function(){

    $("ul#artists li").hover(function() { /* On hover */

    var thumbOver = $(this).find("img").attr("src"); /* Find image source */

    /* Swap background */

    $(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') center bottom no-repeat'}); 
    $(this).find("span").stop().fadeTo('fast', 0 , function() {
        $(this).hide()
    }); 
    } , function() {
        $(this).find("span").stop().fadeTo('fast', 1).show();
    });

});

</script>

3 - the artist select - works in IE 8 3 - 艺术家选择 - 在IE 8中工作

<script>
    $("#browse-select").change(function() {
    window.location.href = $(this).val();
});
    </script>

These scripts were done by referencing previously made scripts, like I said I'm still new to jQuery. 这些脚本是通过引用以前制作的脚本完成的,就像我说我还是jQuery的新手。 The second works in IE8 and the first one is the one that doesn't. 第二个在IE8中工作,第一个在没有。 I noticed the third one, the only one working, is written differently than the first two non-working ones without a function declaration at the top. 我注意到第三个,唯一一个工作,与前两个没有功能声明的前工作不同。 Could this have anything to do with it? 这跟它有什么关系吗?

Any help figuring out this problem would be so appreciated. 任何帮助解决这个问题的人都会非常感激。

Thanks a lot, Wade 非常感谢,韦德

You don't post the actual JavaScript code but the PHP you've posted probably creates objects with trailing commas: 您不发布实际的JavaScript代码,但您发布的PHP可能会创建带尾随逗号的对象:

{foo: 1, bar: 2,}

Internet Explorer doesn't support that. Internet Explorer不支持该功能。 You must generate something like: 你必须生成类似的东西:

{foo: 1, bar: 2}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM