Wonder how to you get the size of a visitor’s computer screen ? Yes, you might need it for some cases where you want to display content of your website correctly according to the screensize of the user’s computer, mobile, iPhone, Android device or any other smartphone.
You can detect screensize and the useable are of the screen by using the “screen” object.
|screen.height||shows the height of the screen|
|screen.width||shows the width of the screen|
|screen.availHeight||shows height but removes the interface height like taskbar, and browser menu etc.|
|screen.availWidth||same as above,instead gives available width|
screen is the object of window, but sometimes it might not work for all browsers. In that case we utilize the DOM. Using document.body you can get the height and width of the browser window.
I have written the following function, which will allow you to get height and width from different browsers.
Hope that helps
Stay Digified !!