0

弹出窗口在 Firefox 和 Safari 中有效,但在 Internet Explorer 9 中无效。使用 Internet Explorer 9 中的开发工具,我收到以下错误(发生在函数 openPopUp 中)。

SCRIPT438:对象不支持此属性或方法 script2.js,第 92 行字符 5

这是 <script2.js>

var popup_content_cache = '';
var popup_content_src_id = '';
jQuery.fn.center = function () {
    console.log("*****NEW******");
    this.css("position", "absolute");
    this.css("top", (($(window).height() - this.outerHeight()) / 2) +
                                                $(window).scrollTop() + "px");
    this.css("left", (($(window).width() - this.outerWidth()) / 2) +
                                                $(window).scrollLeft() + "px");

    console.log(this.css('top'));
    console.log(parseInt(this.css('top')));
    if (parseInt(this.css('top')) < 0) this.css('top', '20px');

    console.log(parseInt(this.css('top')));
    return this;/*
    this.css("position","absolute");
    var top=($(window).height() - this.outerHeight())/2;

    console.log("top:  " + top)
    console.log($(window).height());
    console.log(this.outerHeight());
    if(top<0){
        console.log("** IF");
        this.css("top", "20px");
        this.css("left", (($(window).width() - this.outerWidth()) / 2) +   $(window).scrollLeft() + "px");
    }
    else {
        this.css("top", (($(window).height() - this.outerHeight()) / 2) +
                                                    $(window).scrollTop() + "px");
        this.css("left", (($(window).width() - this.outerWidth()) / 2) +
                                                    $(window).scrollLeft() + "px");
    }
    console.log();
    return this;*/
}

function openLayerBC() {
    tWidth = $(document).width();
    tHeight = $(document).height();
    //$("select").fadeOut('fast');
    $('#filter').css("width", tWidth + "px");
    $('#filter').css("height", tHeight + "px");
    // $('#filter').css('z-index',9990);
    $("#filter").css("opacity", 0.8);
    $('#filter').fadeIn('fast');

    //$('#filter').bind("click",closePopup1);
    $('#filter,#close').click(function () {
        $('#filter').fadeOut('fast');
        $('#case_light_box').hide();
        o = document.getElementById('divid');
        o.style.display = o.style.display === 'block' ? 'none' : 'block';
    });
}

function closePopup() {
    $('#filter').fadeOut('fast');
    o = document.getElementById('popup');
    o.style.display = 'none';

    // o.style.display = o.style.display=='block'?'none':'block';
    $(o).css("position","absolute");
    $(popup_content_src_id).html(popup_content_cache);
    var popup_content_cache = '';
    var popup_content_src_id = '';
}

function openPopUp(div) {
    openLayerBC();

    div = div.replace('#', '');
    file = div;
    page = '/v/vspfiles/templates/OSS/ajax/products/' + div + '.html';
    $.get(page, {}, function(data)
    {
        msgbox = document.getElementById('popup');
        $(msgbox).html(data);
        $(msgbox).css('width',$('#'+div).css('width'));
        $('#'+div).show();

        $(msgbox).center();
        $(msgbox).show();
    });
}

以下是消息所指的 <script2.js> 的第 92 行。

 page = '/v/vspfiles/templates/OSS/ajax/products/'+div+'.html';

免责声明:我继承了这段 JavaScript 代码,并且对 JavaScript 及其语法几乎没有经验。

4

2 回答 2

1

尝试在“page”之前添加“var”:

var page = '/v/vspfiles/templates/OSS/ajax/products/'+div+'.html';
于 2012-10-12T17:00:53.657 回答
0

page看起来它可能是未定义的。此外, div 或 page 可能不是字符串。您可以打开一个开发者控制台,debugger;在错误之前放置一条语句,并在抛出错误之前检查divpage变量以缩小范围。

于 2012-05-25T18:19:57.757 回答