IE7 is not positioning dialog properly on window resize
Like I said, IE7 (and IE6 but I don't really care IE6 that much) doesn't position dialog properly on window resize. When window is re sized, dialog goes down and down. IE8 FF Chrome Safari all work properly and position and re size dialog just fine but IE7 it re sizes the dialog but positions incorrectly. Anybody know some fix about this?
$("#mydialog").dialog({
autoOpen: false,
bgiframe: true,
resizable: false,
modal: true,
title: "",
height: 400,
overlay: {
backgroundColor: '#000',
opacity: 0.5
}
});
$(window).resize(function(){
$('#mydialog').dialog("option", "height", $(window).height() - 40);
$('#mydialog').开发者_运维问答dialog('option', 'position', 'center');
});
$("#mydialog").dialog("open");
Ok here is a workaround I found, it's a bit slow but it works.
$(window).resize(function(){
$('#mydialog').dialog("option", "height", $(window).height() - 40);
$('#mydialog').dialog('option', 'position', 'center');
if ($.browser.msie && parseInt($.browser.version) <= 7) {
$('#mydialog').dialog('close');
$('#mydialog').dialog('open');
}
});
I ran into this recently and discovered a faster and more appropriate fix for IE7, simply set the body's css property to relative, accounting for the way IE7 handles the window object.
Since you are using jQuery, the following should work:
$('body').css("position", "relative");
I also created the following to illustrate the issue and solution: http://jsfiddle.net/ewsang/7PpcV/
精彩评论