-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex12.html
More file actions
34 lines (32 loc) · 983 Bytes
/
ex12.html
File metadata and controls
34 lines (32 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>navigator</title>
</head>
<body>
<div id="dics">기기 정보: </div>
<button class="btn" id="btn1" onclick="nav()">기기 판별</button>
<button class="btn" id="btn2" onclick="print()">출력</button>
<div id="res"></div>
<script>
var dics = document.getElementById("dics");
var res = document.getElementById("res");
function nav(){
var isMobile = /iPhone|iPad|iPod|Andorid/i.test(navigator.userAgent);
if(isMobile){
dics.innerHTML="Mobile";
}
else{
dics.innerHTML="Desktop";
}
}
function print(){
for(var key in navigator){
res.innerHTML+= key+" "+navigator[key]+"<br>";
}
}
</script>
</body>
</html>