$(window).width() not working in IE9

2020-03-26 08:07发布

I am doing something like follow:

// 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);

But looks like it's not working in IE9.

2条回答
贪生不怕死
2楼-- · 2020-03-26 08:23

Use:

$(window).innerHeight();
$(window).innerWidth();
查看更多
虎瘦雄心在
3楼-- · 2020-03-26 08:36

Try this:

var maskWidth = window.innerWidth;
var maskHeight = window.innerHeight;

Or in IE 6+ in standards compliant mode:

var maskWidth = document.documentElement.clientWidth;
var maskHeight = document.documentElement.clientHeight;
查看更多
登录 后发表回答