【发布时间】:2012-02-09 17:03:53
【问题描述】:
我正在做类似以下的事情:
// get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
// calculate the values for center alignment
var dialogLeft = (maskWidth/2) - ($('#dialog-box').width()/2);
但看起来它在 IE9 中不起作用。
【问题讨论】:
-
到底做错了什么?
-
他不知何故向右移动
-
@Saurabh 您应该缓存您的
$('#dialog-box')参考:var dialog = $('#dialog-box')[0];(在页面加载时),然后在需要时使用$(dialog)... -
@Saurabh
$(window).width()应该可以正常工作。问题出在其他地方...您能提供问题的屏幕截图吗?
标签: javascript jquery internet-explorer-9 cross-browser