JQuery window width not correct in Chrome

by November 16, 2015 0 comments
In some cases, $(window).width() doesnt return correct width of window, maybe because of scroll bar. So one of solution work for me i:

function viewport() {
 var e = window, a = 'inner';
 if (!('innerWidth' in window)) {
   a = 'client';
   e = document.documentElement || document.body;
 }
 return { width: e[a + 'Width'], height: e[a + 'Height'] };
}
 viewport().width

An Nguyen

Developer

Sharing daily exciting lesson learned and posts about .NET, SQL Server, HTML, Javascript - jQuery, CSS - Bootstrap, SalesForce CRM, Kentico CMS and so on.

0 comments :

Post a Comment