How to get the screen size in Javascript

This tutorial shows how to get the size resolution in Javascript.

Create the following javascript:

<script language="javascript">
	document.write( 'Screen width = ' + screen.width + 'px');
	document.write( '<br/>Screen height = ' + screen.height + 'px');
</script>

The output will be:


The same way, you can get the window size using jquery

Create the following javascript:

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"> var a;</script> 
    
<script language="javascript">
	document.write( 'Window width = ' + $( window ).width() + 'px');
	document.write( '<br/>Window height = ' + $( window ).height() + 'px');
</script>

The output will be:

References:

jQuery

Recent Comments