Getting The Screen Resolution Using JavaScript

Most of developers struggle with the same problem when developing project how to get visitors system resolution and according to resolution set some default css, JavaScript code and show different different images for different different screen resolution.
So don’t worry here is solution of this problem we can easily do it using Couple of lines JavaScript code.
Below that we are explaining one example “How to include image according to screen resolution using JavaScript” using this example you can understand how it is working.

Example : How to include image according to screen resolution using JavaScript

<script type="text/javascript">
if(screen.width <= 800){
    documnet.write('<img src="image/demo1.jpg"/>');
}else{
    documnet.write('<img src="image/demo2.jpg"/>');
}
</script>

Leave a Reply

Related Posts: You may like

How To Create a Modal Popup With CSS and JavaScript

Get Latitude Longitude from Address

cookie policy popup

How to make a sticky sidebar on scroll

PHPKIDA Offering Free Tools:

INSTA DOWNLOADER

Download Instagram Videos & Photos.

Download Now

CURRENCY CONVERTER

Real Time Currency Converter

Convert Now

ROBOST.TXT GEN.

Robots.txt File Creater

Create Now

HTML MINIFIER

Compress yout HTML Code

Minify Now

CSS MINIFIER

Compress yout CSS Code

Minify Now

JAVASCRIPT MINIFIER

Compress yout JavaScript Code

Minify Now

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.