How to get screen size IOS and Android by jquery

var isiDevice = /ipad|iphone|ipod/i.test(navigator.userAgent.toLowerCase());
var isAndroid = /android/i.test(navigator.userAgent.toLowerCase());

if (isiDevice) {
$(window).on(“orientationchange”, function () {
var ori = window.orientation;
widthWindow = $(window).width();
$(‘.tr-message-staff .mess_txt’).width(widthWindow – distanceLengthWinAndMessage – 55);
$(‘.tr-message-guest .mess_txt’).width(widthWindow – distanceLengthWinAndMessage);
});
} else if (isAndroid) {
$(window).on(“orientationchange”, function () {
var ori = window.orientation;
widthWindow = screen.availWidth;
$(‘.tr-message-staff .mess_txt’).width(widthWindow – distanceLengthWinAndMessage – 55);
$(‘.tr-message-guest .mess_txt’).width(widthWindow – distanceLengthWinAndMessage);
});
}

Note: The availWidth property returns the width of the user’s screen, in pixels, minus interface features like the Windows Taskbar.

The innerWidth property returns the inner width of a window’s content area.

The screen.width property returns the width of the visitor’s screen in pixels.

Leave a comment