javascript to detect whether page is load on mobile or desktop

Solutions on MaxInterview for javascript to detect whether page is load on mobile or desktop by the best coders in the world

showing results for - "javascript to detect whether page is load on mobile or desktop"
Matteo
22 Jan 2016
1<!DOCTYPE html>
2<html>
3<head>
4	<title>Mobile Test</title>
5</head>
6<body>
7
8	<p id="text"></p>
9
10	<script type="text/javascript">
11		var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
12		var element = document.getElementById('text');
13		if (isMobile) {
14  			element.innerHTML = "You are using Mobile";
15		} else {
16			element.innerHTML = "You are using Desktop";
17		}
18	</script>
19</body>
20</html>
21