when using SimpleModal and open an Iframe it is ca

2019-06-22 05:24发布

问题:

I am using SimpleModal and i am opening an Iframe (using ff) it seems to work ok in ie9 but in ff it is calling the iframe src twice

Thanks for any help

the code i am calling looks like

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:

I ran into the same problem. Looking at the plugin code...

// 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;

You can see the data is added to the page body with the line .appendTo('body'); to calculate the correct dimensions for the modal. If you comment out this line, it will prevent the iframe being called twice.

// 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;

Not sure if this modification will cause your modal size to have the wrong dimensions, but my iframe was set to width=100% and height=100% so didn't affect me.