Sugeriría (se necesita jQuery):
/*
* windowSize
* call this function to get windowSize any time
*/
function windowSize() {
windowHeight = window.innerHeight ? window.innerHeight : $(window).height();
windowWidth = window.innerWidth ? window.innerWidth : $(window).width();
}
//Init Function of init it wherever you like...
windowSize();
// For example, get window size on window resize
$(window).resize(function() {
windowSize();
console.log('width is :', windowWidth, 'Height is :', windowHeight);
if (windowWidth < 768) {
console.log('width is under 768px !');
}
});
Agregado en CodePen:
http://codepen.io/moabi/pen/QNRqpY?editors=0011
Entonces puede obtener fácilmente el ancho de la ventana con var: windowWidth y Height con: windowHeight
de lo contrario, obtenga una biblioteca js:
http://wicky.nillia.ms/enquire.js/