JavaScript

How to Detect Screen Resolution with JavaScript

You can simply use the width and height properties of the window.screen object to retrieve the screen resolution (i.e. the width and height of the screen).

The following example displays the resolution of your screen by clicking on the “Get Resolution” button.
 

How to Detect Screen Resolution with JavaScript
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Detect Screen Resolution</title>
		<script>
			function getResolution() {
				alert("Your screen resolution is: " + screen.width + "x" + screen.height);
			}
		</script>
	</head>
	<body>
		<button type="button" onclick="getResolution();">Get Resolution</button>
	</body>
</html>
Result
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More [st_adsense]

Leave a Reply

Your email address will not be published. Required fields are marked *