开发者

Javascript errors in IE

开发者 https://www.devze.com 2023-02-01 03:41 出处:网络
Please help me correct the mistake in javascript, it doesn\'t work in IE, i just can\'t understand what is the problem here:

Please help me correct the mistake in javascript, it doesn't work in IE, i just can't understand what is the problem here:

   $(document).ready(function() {
        $(".image2").click(function() {var image = $(this).attr("rel");
        $('#image2').hide();
        $('#image2').fadeIn('slow');
        $('#image2').html('<embed height="253" width="440" wmode="transparent" src="' + image + '"></embed>');
        var image2 = $('#image2 embed').attr('src');
        $("#thumb2 a img").removeClass("open");
        $("#thumb2 a[rel='" + image2 + "'] img").addClass("open");
        return false;
        });
    });
    $(document).ready(function() {  
        var image3 = $('#image2 embed').attr('src');
        $("#thumb2 a[rel='" + image3 + "'] img").addClass("open");

        var n = $('#news_list');    
        n.find('.list_news a').css({opacity: 0.5}).hover(
            function() { $(this).css({opacity: 1}); },
            function() { $(this).css({opacity: 0.7}); }
        );
        n.hover(
            function() { $(this).find('a').css({opacity: 0.7}); },
            function() { $(this).find('a').css({opacity: 0.5}); }
        );
    });

    $(document).ready(function() {  
        $('.image').click(function(event) {
        event.preventDefault();
        var imagePath = $(this).attr("href");
        var newImg = new Image;
        newImg.src = imagePath;
        newImg.onload 开发者_运维技巧= function(){
            $('#big_picture').hide();
            $('#big_picture').attr('src', imagePath);
            $('#big_picture').fadeIn('slow');
        };
        });
    });

    $(document).ready(function() {  
        $(".dropdown a").each(function() {
        if(this.href == window.location) 
        $(this).addClass("open");
        });

        $('.slider_fade').cycle({ 
        fx:     'fade',
        timeout: 7000,
        });
    });
    $('.upper_menu_link').attr('target', '_blank');

    var message="";
    function clickIE() {if (document.all) {(message);return false;}}
    function clickNS(e) {if 
    (document.layers||(document.getElementById&&!document.all)) {
    if (e.which==2) {
    (message);
    return false;}}}
    if (document.layers) {
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown=clickNS;
    }else{
    document.onmouseup=clickNS;
    document.oncontextmenu=clickIE;
    }
    document.oncontextmenu=new Function("return false");

        $('.urun_div').corner("round 20px");


The comma after timeout: 7000 is the problem.

More info on Internet Explorer's trailing comma woes.

Sometimes I search my code for these using regular expressions similar to those in the previous link whenever my code fails in IE but works in other browsers.

Also, the Javascript Lint can be of massive help with mistakes like this one.


Recent versions of Internet Explorer come with a passable set of developer tools (accessed by pressing F12), if you use these they will tell you things like what line number your error occurred on, what type of error it was (syntax, NaN, undefined etc).

0

精彩评论

暂无评论...
验证码 换一张
取 消