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>
Mukesh Jakhar - PHP Web Developer
Mukesh Jakhar

This is Mukesh Jakhar. I’m a professional web developer with 3+ years experience. I am always ready for freelance work and i am writing blogs in my free time. I love to learn new technologies and share with others.

I founded PHPKIDA in September 2015. The focus of this website to provide web development tutorials of PHP, WordPress, CodeIgniter, Jquery, MySQL, HMTL, CSS etc and sharing solution to problems which i already solved.

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.