【发布时间】:2017-09-27 18:19:45
【问题描述】:
我在 DIV 中嵌入了一个 IFrame 源(JQuery-UI Datepicker)。当用户在 iframe 内单击以选择日期时,iframe 的宽度和高度应增加以适应 datepicker-calender 的高度。日期选择完成后,IFrame 应该恢复到其原始大小。
JSFiddle : https://jsfiddle.net/Jersey_Guy/yoc9jewv/
$(document).ready(function() {
//debugger;
var $w = $(window),
$dateframe = $("iframe[src*='jqueryui']");
$dateframe.blur(function() {
console.log("Called Resize");
$(this).width = 100;
$(this).height = 100;
}).resize();
$dateframe.click(function() {
console.log("Called Resize");
$(this).width(200);
$(this).height(400);
}).resize();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="tab-zone tab-widget tabZoneSelected tabSuppressVizTooltipsAndOverlays tabZone-web fade-bg" id="tabZoneId1" style="z-index: 17; background-color: rgba(255, 255, 255, 0); width: 474px; height: 127px; top: 5px; left: 3px;">
Outer Div
<div class="tab-web tab-widget fade-in">
Inner Div
<div style="position: absolute;">
IFrame Floater Div
<iframe name="frame_1" src="https://jqueryui.com/resources/demos/datepicker/default.html" style="border: 0px none; width: 200px; height: 80px; top: 0px; left: 0px;">
</iframe>
End IFrame Div
</div>
End Inner Div
</div>
End Outer Div
</div>
我需要设置 div 大小和 IFrame 大小吗? 我哪里错了?
【问题讨论】:
-
是 iFrame 跨域吗?
-
实际情况并非如此,但该示例确实使用了不同来源的html作为示例。
标签: javascript jquery html iframe jquery-ui-datepicker