Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser size (width and height)

I'm trying to detect the browser's current size (width and height). I know it's super easy in jQuery with $(document).width and $(document).height, but I don't want to add the size of the jQuery lib to the project, so I'd rather just use built in JavaScript. What would be the short and efficient way to do the same thing with JavaScript?

like image 951
dono Avatar asked Mar 18 '10 23:03

dono


People also ask

What is the standard browser size?

According to the Worldwide Screen Resolution Stats (Sept 2021 – Sept 2022), the most common screen resolutions across mobile, desktop, and tablet are: 1920×1080 (9.94%) 1366×768 (6.22%) 360×640 (5.88%)

How do I find my browser width and height?

Use window. innerWidth and window. innerHeight to get the current screen size of a page.

What is browser width?

The 'Browser width - bucketed' dimension shows the width of the browser window, classified in groups of 100 pixels. This dimension is useful when you want to understand how wide visitors see your content. Understanding how wide your content is typically viewed can allow you to optimize content for viewing.

What is the size of web page?

Which Is The Standard Webpage Size? The standard webpage size uses a maximum width of 1440 pixels for Desktops. This is because most desktop resolutions use a wider resolution nowadays (1920x1080). However, most websites are fully responsive nowadays, which means they won't use fixed dimensions.


1 Answers

// first get the size from the window // if that didn't work, get it from the body var size = {   width: window.innerWidth || document.body.clientWidth,   height: window.innerHeight || document.body.clientHeight } 
like image 183
Joel Avatar answered Sep 17 '22 16:09

Joel