简体   繁体   English

jQuery UI对话框未在IE9中设置“ left”属性

[英]jQuery UI Dialog doesn't set “left” property in IE9

For some reason, when I try to use jQuery dialog in IE9, it doesn't apply any left property to it leaving it at 0 which makes the dialog stay all the way to the left. 出于某种原因,当我尝试在IE9中使用jQuery对话框时,它没有应用任何left属性,因此将其保留为0,这使对话框一直保持在最左边。 It works fine in all other browsers including IE 7 and 8. 它在所有其他浏览器(包括IE 7和8)中都可以正常工作。

Here's the code for initializing and opening the dialog: 这是初始化和打开对话框的代码:

jQuery('#form-holder').dialog({
        autoOpen: false, modal: true, closeOnEscape: true, width: 680, closeText: '', close: closeDialog
    });

jQuery('#form-holder').dialog('open');

I tried to apply the following code to manually set that property, but it didn't work either: 我尝试应用以下代码来手动设置该属性,但是它也不起作用:

var ua = jQuery.browser;
if (ua.msie && ua.version.slice(0, 3) == "9.0") {
jQuery('div.ui-dialog').css('left', '294px');
}

The resulting HTML after opening the dialog: 打开对话框后的结果HTML:

<div tabIndex="-1" class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable ui-resizable" role="dialog" aria-labelledby="ui-dialog-title-form-holder" style="left: 0px; top: 384px; width: 680px; height: auto; display: block; position: absolute; z-index: 1002; outline-width: 0px; outline-style: none; outline-color: invert;">

Is there any known compatibility issues of jQuery UI and IE9? jQuery UI和IE9是否存在任何已知的兼容性问题?

try this, there is no need to use px , jQuery will take care of that; 试试看,不需要使用px ,jQuery会解决的;

if (jQuery.browser.msie && jQuery.browser.version == '9.0') {
      $('div.ui-dialog').css('left', '294');
}

打开后设置位置:

$("#form-holder").dialog( "option", "position", [294,384] );

Try removing the quotation marks in the value passed to the top parameter in the jquery css function: 尝试删除传递给jquery css函数中top参数的值中的引号:

if (ua.msie && ua.version.slice(0, 3) == "9.0") {
jQuery('div.ui-dialog').css('left', 294);
}

Hope it helps! 希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM