Answers for "JavaScript to detect whether page is load on Mobile or Desktop"

0

JavaScript to detect whether page is load on Mobile or Desktop

<!DOCTYPE html>
<html>
<head>
	<title>Mobile Test</title>
</head>
<body>

	<p id="text"></p>

	<script type="text/javascript">
		var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
		var element = document.getElementById('text');
		if (isMobile) {
  			element.innerHTML = "You are using Mobile";
		} else {
			element.innerHTML = "You are using Desktop";
		}
	</script>
</body>
</html>
Posted by: Guest on July-01-2021

Code answers related to "JavaScript to detect whether page is load on Mobile or Desktop"

Code answers related to "Javascript"

Browse Popular Code Answers by Language