Saurabh Kumar
Saurabh Kumar

Reputation: 16651

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

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.

Upvotes: 3

Views: 5626

Answers (2)

tskuzzy
tskuzzy

Reputation: 36446

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;

Upvotes: 6

Gabriel Ross
Gabriel Ross

Reputation: 5198

Use:

$(window).innerHeight();
$(window).innerWidth();

Upvotes: 3

Related Questions