Jquery mobile 带有Iframe显示的弹出窗口JQM

Jquery mobile 带有Iframe显示的弹出窗口JQM,jquery-mobile,iframe,popup,Jquery Mobile,Iframe,Popup,我的弹出窗口以一种无政府的方式打开,它应该在页面中心以覆盖的方式打开,但它会打开另一个页面,将其放置在带有白色背景的绝对位置。我希望它像在演示jquery中一样打开 这是一个外部弹出窗口 <html> <body> <div data-role="popup" id="popIf" data-overlay-theme="b" data-theme="a" data-tolerance="15,15" class="ui-conten

我的弹出窗口以一种无政府的方式打开,它应该在页面中心以覆盖的方式打开,但它会打开另一个页面,将其放置在带有白色背景的绝对位置。我希望它像在演示jquery中一样打开

这是一个外部弹出窗口

    <html>
    <body>
        <div data-role="popup" id="popIf" data-overlay-theme="b" data-theme="a" data-tolerance="15,15" class="ui-content"><iframe src="add.html" width="445" height="225" seamless=""></iframe></div>
        <div data-role="page" id="myfirstpage">
JS==>

$( document ).on( "pagecreate", function() {
// The window width and height are decreased by 30 to take the tolerance of 15 pixels at each side into account
function scale( width, height, padding, border ) {
    var scrWidth = $( window ).width() - 30,
        scrHeight = $( window ).height() - 30,
        ifrPadding = 2 * padding,
        ifrBorder = 2 * border,
        ifrWidth = width + ifrPadding + ifrBorder,
        ifrHeight = height + ifrPadding + ifrBorder,
        h, w;
    if ( ifrWidth < scrWidth && ifrHeight < scrHeight ) {
        w = ifrWidth;
        h = ifrHeight;
    } else if ( ( ifrWidth / scrWidth ) > ( ifrHeight / scrHeight ) ) {
        w = scrWidth;
        h = ( scrWidth / ifrWidth ) * ifrHeight;
    } else {
        h = scrHeight;
        w = ( scrHeight / ifrHeight ) * ifrWidth;
    }
    return {
        'width': w - ( ifrPadding + ifrBorder ),
        'height': h - ( ifrPadding + ifrBorder )
    };
};
$( ".ui-popup iframe" )
    .attr( "width", 0 )
    .attr( "height", "auto" );
$( "#popIf" ).on({
    popupbeforeposition: function() {
        // call our custom function scale() to get the width and height
        var size = scale( 445, 225, 15, 1 ),
            w = size.width,
            h = size.height;
        $( "#popIf iframe" )
            .attr( "width", w )
            .attr( "height", h );
    },
    popupafterclose: function() {
        $( "#popIf iframe" )
            .attr( "width", 0 )
            .attr( "height", 0 );
    }
});
});

是否初始化外部弹出窗口?在pagecreate事件的开头添加此行:

$("#popIf").popup().enhanceWithin();
另外,您如何启动弹出窗口?确保您将位置设置为窗口:

<a href="#popIf" data-rel="popup" class="ui-btn ui-corner-all ui-shadow ui-btn-inline" data-transition="pop" data-position-to="window">Basic Popup</a>
这是一个


谢谢伙计,你解决了我的问题,我还注意到我的按钮没有数据rel=弹出窗口