Jquery - IE中的问题

时间:2010-01-06 10:31:02

标签: jquery

我已经通过下载未压缩版本的jquery1.2.3.js解决了这个问题。我查找导致错误的行。这是1061.代码是......

if(set)
elem[name] = value;
return elem[name];

我不得不删除此代码以使jquery在IE中工作。这是一个主要问题。我不确定这段代码是否缺乏重复。建议请。

以下jquery代码在Firefox中正常工作但在IE中引发错误。有人可以请帮助。有什么建议吗?

错误说明......

Invlalid Argument
jquery1.3.2.js Line 12
Code:0  Char: 12949

当我删除内联函数mylib.showreel.init();时,错误消失,因此实际错误是由以下代码而不是jquery引起的。

showreel :
{
    init : function() {
        $('#showreel-content').hide();
        $('#showreel').addClass('loading');

        $.ajax({
            type: "GET",
            url: "/xml/showreel.xml",
            dataType: "xml",
            success: function(xml) {

                var total = $(xml).find('site').length;
                var randnum = Math.floor(Math.random()*total);

                $(xml).find('site').each(function(entryIndex, entry) {
                    if(entryIndex === randnum){
                        var title = $(this).find('title').text();
                        var color = $(this).find('color').text();
                        var url = $(this).find('url').text();
                        var website = $(this).find('website').text();
                        var image = $(this).find('image_src').text();

                        $('#head-contact,#head-contact a').css('color',color);
                        $('body.home #nav li#home').css('border-bottom','1px solid' + color);

                        $('<div id="info"></div>')
                        .html('<div class="entry" style="color:' + color + '">' + title + '<a href="'+url+'"><br />'+website+'</a></div>')
                        .appendTo('#header-content');


                        //create new image object to preload image
                        var img = new Image();
                        //once image has loaded execute this code
                        $(img).load(function () {
                            //$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
                            $(this).hide();
                            $('#showreel').removeClass('loading').append(this);
                            $(this).fadeIn('slow');
                            }).error(function () {
                            // notify the user that the image could not be loaded
                        }).attr('src', image);

                    }
                });

            }//end success function
        });//end ajax function
    }//end init
}//end showreel

2 个答案:

答案 0 :(得分:0)

得到了解决。实际上是这行代码......

$('body.home #nav li#home').css('border-bottom','1px solid' + color);

我只是在固体之后添加了一个空格。解决这么简单但耗费时间。洛尔

$('body.home #nav li#home').css('border-bottom','1px solid ' + color);

答案 1 :(得分:0)

尝试在jquery 1.3.2上使用此代码非缩小...在第1061/1051行附近,替换此代码:

if ( set )
elem[ name ] = value;
return elem[ name ];
} to:

    var FixedValue = "" + value;
    if (FixedValue.length >= 3 && FixedValue.substr(0,3) == "NaN") { value = ""; }
    if ( value != undefined )
            elem[ name ] = value;
            return elem[ name ];
        },