Thursday, November 17, 2011

jquery client browser width/height


In webpages we need to format the images text differently according to the screen resolution of the user.
Below is code to detect browser width and  height. You can write your code according the condition.
To get screen width or height use function:
var winHeight = $(window).height();
var winWidth  = $(window).width();
$(document).ready(function() {
if ((screen.width>=1024) && (screen.height>=768)) {
// statement
}
else  {
//statement
}
});
$(document).ready(function() {
$(window).resize(function() {
if ($(window).height() < 800) {
//statement
}
else {
//statement
}
});
});

No comments: