После демонстрации здесь: https://demos.jquerymobile.com/1.2.1/docs/pages/popup/popup-iframes.html
Я пытаюсь поместить iframe в затененный оверлей поверх текущего документа html. Желание, чтобы iframe начинался скрытым. Триггер, как и ссылка, должен отображать iframe. Приведенный ниже код почти отражает код из Jquery документов.
<!DOCTYPE html>
<html>
<head>
<title>testmessage</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
// popup examples
$( document ).on( "pageinit", function() {
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" );
$( "#popupVideo" ).on({
popupbeforeposition: function() {
// call our custom function scale() to get the width and height
var size = scale( 497, 298, 15, 1 ),
w = size.width,
h = size.height;
$( "#popupVideo iframe" )
.attr( "width", w )
.attr( "height", h );
},
popupafterclose: function() {
$( "#popupVideo iframe" )
.attr( "width", 0 )
.attr( "height", 0 );
}
});
});
</script>
<style>
iframe { border: none; }
#popupPanel-popup {
right: 0 !important;
left: auto !important;
}
#popupPanel {
width: 200px;
border: 1px solid #000;
border-right: none;
background: rgba(0,0,0,.5);
margin: -1px 0;
}
#popupPanel .ui-btn {
margin: 2em 15px;
}
</style>
</head>
<body>
<h1>testmessage</h1>
<hr>
<a href="#popupVideo" data-rel="popup" data-position-to="window" data-role="button" data-theme="b" data-inline="true">Launch Iframe Overlay</a>
<div data-role="popup" id="popupVideo" data-overlay-theme="a" data-theme="d" data-tolerance="15,15" class="ui-content">
<iframe src="http://player.vimeo.com/video/41135183?portrait=0" width="497" height="298" seamless></iframe>
</div>
</body>
</html>
Надеюсь, это простая проблема, но я ее не вижу.