मैं सुझाव दूंगा (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 !');
}
});
CodePen में जोड़ा गया:
http://codepen.io/moabi/pen/QNRqpY?editors=0011
फिर आप आसानी से विंडो की चौड़ाई को var के साथ पा सकते हैं: windowWidth और Height with: windowHeight
अन्यथा, एक js लाइब्रेरी प्राप्त करें:
http://wicky.nillia.ms/enquire.js/