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>
About Author

My name is Mukesh Jakhar and I am a Web Application Developer and Software Developer, currently living in Jaipur, India. I have a Master of Computer Application in Computer Science from JNU Jaipur University. I loves to write on technology and programming topics. Apart from this, I love to travel and enjoy the beauty of nature.

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.