代码之家  ›  专栏  ›  技术社区  ›  dr Hannibal Lecter

如何使用iframe正确调整jQuery.ui对话框的大小

  •  2
  • dr Hannibal Lecter  · 技术社区  · 14 年前

    我正在创建iframe和对话框,如下所示:

    someVar = '<iframe id="some-dialog" class="window-frame" src="http://example.com/"></iframe>';
    
    someVar.dialog
        ({
            title: command.buttonText,
            autoOpen: false,
            modal: false,
            resizable: true
        })
        .dialog('option', 'width', 800)
        .dialog('option', 'height', 600);
    

    我试着在init调用中输入宽度和高度,结果是一样的。如果我忽略这两个,对话框将使用默认值初始化,随后的调整大小工作正常。

    更新:

    我将iframe包装在一个div中,然后用一个标准调用创建了一个对话框:

    someVar.dialog
        ({
            title: command.buttonText,
            autoOpen: false,
            modal: false,
            resizable: true,
            width: 800,
            height: 600
        })
    

    真实的 但它是有效的(但感觉很脏!)

    2 回复  |  直到 14 年前
        1
  •  2
  •   Dan Atkinson    12 年前
    someVar = '<iframe id="some-dialog" class="window-frame" src="http://example.com/"></iframe>';
    
    someVar.dialog({
      title: command.buttonText,
      autoOpen: false,
      modal: false,
      resizable: true,
      width:800,
      height:600
    }).width(800-10).height(600-10);
    

    编辑:
    Demo:

        2
  •  5
  •   Ahmad Alfy    12 年前

    iframe#some-dialog {
        width: 100% !important;
        box-sizing: border-box;
        -moz-box-sizing: border-box;
    }