【问题标题】:Problem with jQuery resizable inside iframejQuery在iframe中调整大小的问题
【发布时间】:2010-07-01 14:43:14
【问题描述】:

我有第一页。在哪里打开带有 iframe 的 jQuery 对话框的链接,里面有第二页。 第二页内有一个可调整大小的文本区域。 实际上,仅当我在没有 iframe 的情况下严格打开第二页时,textarea 才可调整大小,但在 iframe 内无法调整大小。 怎么解决?

更新: 这是我第一页的 html 代码:

  1. <div id="dialog-system" title="system settings">
  2.   <div class="loadingDivForDialog"><img src="Control/Image/loading.gif" alt="loading..." /></div>
  3.   <iframe id="SystemFrame" src="" scrolling="no" frameborder="0"></iframe>
  4. </div>
* This source code was highlighted with @987654321@.

这是打开对话框的脚本:

  1. function showSystemDialog(propertyName, id_prov, psysName, currentItemForTick) {
  2.   $('.loadingDivForDialog').show();
  3.   $('#SystemFrame').hide();
  4.  
  5.   var defaultSrc = "Settings.aspx?pro=" + propertyName + "&id_prov=" + id_prov;
  6.   $("#systemFrame").attr('src', String(defaultSrc));
  7.  
  8.   $("#dialog-system").dialog({
  9.     resizable: false,
  10.     height: 300,
  11.     width: 680,
  12.     modal: true,
  13.     position: 'center',
  14.     buttons: {}
  15.   });
  16.   $('#SystemFrame').load(function() {
  17.     $('.loadingDivForDialog').hide();
  18.     $('#SystemFrame').show();
  19.     $('#SystemFrame').contents().find("input[value='Update']").click(function() {
  20.  
  21.       var obj = $("#" + currentItemForTick);
  22.  
  23.       if (obj.get(0).tagName == "INPUT") {
  24.         obj.attr('checked', true);
  25.       }
  26.       else {
  27.         obj = window.parent.$("input[value='" + psysName + "']");
  28.  
  29.         obj.attr("checked", true);
  30.       }
  31.     });
  32.  
  33.     $('#SystemFrame').contents().find("input[value='Cancel']").click(function() { $("#dialog-system").dialog("close") });
  34.  
  35.     $("#dialog-system").dialog("option", "height", parseInt($('#SystemFrame').contents().height(), 10) + 35);
  36.   });
  37.   return false;
  38. }
* This source code was highlighted with @987654322@.

这是第二页的文本区域和脚本:

  1. <textarea name="ctl00$ContentPlaceHolderBody$ctrl02$fldText" rows="2" cols="20" id="ctl00_ContentPlaceHolderBody_ctrl02_fldText" class="textbox"></textarea>
  2.  
  3. <script type="text/javascript">$(function() {
  4.   $("#ctl00$ContentPlaceHolderBody$ctrl02$fldText").resizable({
  5.     handles: "se",
  6.     maxWidth: 340,
  7.     minWidth: 196,
  8.     minHeight: 18
  9.   });
  10. });</script>
* This source code was highlighted with @987654323@.

UPD:有什么想法吗?

【问题讨论】:

  • 看起来可调整大小的插件无法计算元素的高度和宽度。
  • 你能发布一些示例代码吗? iframe 和 jquery 有很多(可悲的)可能出错的地方。
  • 我已经添加了代码。哪些事情可能会出错?
  • 你能解决这个问题吗?我有同样的问题,没有运气。 stackoverflow.com/questions/5670193/…
  • FWIW,你可以看看我想出的这个答案:stackoverflow.com/questions/5670193/…

标签: jquery jquery-ui iframe resizable


【解决方案1】:

当页面上有 iframe 时,我在调整大小时遇到​​了类似的问题。我开始得出结论,iframe 正在阻止相关的鼠标处理程序进入 jQuery 中的调整大小逻辑。

严格来说不是一个解决方案,但它可能会为某人指明正确的方向。

更新:有关潜在修复http://bugs.jqueryui.com/ticket/3176 的更多详细信息,请参阅此 jQuery 票证的最后一条评论

【讨论】:

    猜你喜欢
    • 2011-11-28
    • 2012-03-16
    • 2014-08-30
    • 2011-04-04
    • 1970-01-01
    • 2011-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多