当使用SimpleModal并打开Iframe时,它会调用src两次

时间:2010-12-02 01:09:58

标签: iframe simplemodal

我正在使用SimpleModal,我正在打开一个iframe(使用ff) 它似乎在ie9中工作正常,但在ff中它调用iframe src两次

感谢您的帮助

我调用的代码看起来像

function addNew(){
    var src = "/php/ftp/parsehome.php?dir="+userDir+"&idx=new";
    $.modal('<iframe src="' + src + '" height="445" width="800" style="border:0">', {
          containerCss:{
              backgroundColor:"#E1EFF7",
              borderColor:"#00A99D",
              height:450,
              padding:0,
              width:840
              },
              modal: true
           });
}

1 个答案:

答案 0 :(得分:2)

我遇到了同样的问题。看一下插件代码......

// add styling and attributes to the data
// append to body to get correct dimensions, then move to wrap
s.d.data = data
    .attr('id', data.attr('id') || s.o.dataId)
    .addClass('simplemodal-data')
    .css($.extend(s.o.dataCss, {
        display: 'none'
    }))
    .appendTo('body');
data = null;

您可以看到data已添加到页面正文中,并使用行.appendTo('body');来计算模式的正确尺寸。如果你注释掉这一行,它将阻止iframe被调用两次。

// add styling and attributes to the data
// append to body to get correct dimensions, then move to wrap
s.d.data = data
   .attr('id', data.attr('id') || s.o.dataId)
   .addClass('simplemodal-data')
   .css($.extend(s.o.dataCss, {
      display: 'none'
   }));
data = null;

不确定此修改是否会导致您的模态尺寸尺寸错误,但我的iframe设置为width=100%height=100%因此不会影响我。