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

ran*_*ndy 5 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
           });
}
Run Code Online (Sandbox Code Playgroud)

小智 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;
Run Code Online (Sandbox Code Playgroud)

您可以看到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;
Run Code Online (Sandbox Code Playgroud)

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