UI对话框会自动设置iframe宽度

UI对话框会自动设置iframe宽度

本文介绍了jQuery UI对话框会自动设置iframe宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问为什么jQuery UI对话框自动将宽度设置为自动"?

I want to ask why jQuery UI dialog is setting the width to "auto" automatically?

下面是要构建对话框的iframe.

Below is my iframe to be constructed a dialog.

<iframe id="pklist3" class="ui-dialog-content ui-widget-content" frameborder="0" src="http://localhost/picker" style="width: 570; height: 410px; min-height: 0px;" scrolltop="0" scrollleft="0">

它具有固定的宽度和高度.但是每次我调用"dialog('open')"时,宽度都会自动变为"auto".至于高度,它被设置为某个固定值(我猜它是由jQuery UI计算的)

It has a fixed width and height. But every time I call the "dialog('open')" the width gets to "auto" by itself. As for the height it was set to some fixed value (I guess it's calculated by jQuery UI)

初始化对话框时,我已经设置了宽度和高度.像这样:

I already set the width and height when initializing the dialog.Like this:

var dg = {};
dg.title = this.title;
dg.autoOpen = false;
dg.modal = true;
dg.overlay = {
opacity: 0.4,
background: "#000"
        };
dg.resizable = false;
$('#pklist3').dialog(dg); //iframe width is still fixed value up to this line

但是之后:

$('#pklist3').dialog('open'); //iframe width gets "auto" automatically

这是已知行为吗?有没有办法我们自己定义iframe的宽度和高度?

Is this a known behavior? Is there a way we can define the width and height of the iframe by ourselves?

PS.我正在使用jQuery UI 1.8.16和jQuery 1.6.2并且启动对话框时,iframe的宽度不会改变.只有在我调用dialog('open')

PS. I'm using jQuery UI 1.8.16 and jQuery 1.6.2and the width of the iframe doesn't change when I initiate the dialog. It only change after I call dialog('open')

推荐答案

如果其他任何人都在处理此问题并像我一样偶然发现了这篇文章,我最终在以下位置找到了对我有用的解决方案: ="http://enotacoes.wordpress.com/2012/04/19/setting-iframe-width-in-jquery-dialog/" rel ="noreferrer"> http://enotacoes.wordpress.com/2012/04 /19/setting-iframe-width-in-jquery-dialog/

In case anyone else is dealing with this issue and stumbles upon this post, as I did, I eventually found a solution that worked for me at: http://enotacoes.wordpress.com/2012/04/19/setting-iframe-width-in-jquery-dialog/

基本上,您可以在iframe样式中设置最小宽度,而不是(或另外设置)宽度样式.

Basically, you set the min-width in the iframe style instead of (or additionally with) the width style.

<iframe src="someurl" width="100%" height="100%" frameborder="0"
        scrolling="no" style="min-width: 95%;height:100%;"/>

这篇关于jQuery UI对话框会自动设置iframe宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 12:53