-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNavigator.js
More file actions
96 lines (59 loc) · 1.97 KB
/
Copy pathNavigator.js
File metadata and controls
96 lines (59 loc) · 1.97 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// To check touch event-
console.log(navigator.maxTouchPoints);
// To check the website-
console.log(navigator.vendor);
// To check the version information about the browser-
console.log(navigator.appVersion);
// 4- To check the Operating system on the client machine.
console.log(navigator.platform);
// 5- To Find whether it is mobile or desktop-
console.log(navigator.userAgent);
// regex to check it is iPhone or android-
(navigator.userAgent.match(/iPhone/i))
// To find the product name of the browser engine:
console.log(navigator.product);
javaEnabled
console.log(navigator.javaEnabled());
onLine
// It will check the network status it is online or offline.
console.log(navigator.onLine);
language
console.log(navigator.language);
cookieEnabled
console.log(navigator.cookieEnabled)
appCodeName
console.log(navigator.appCodeName);
appName
console.log(navigator.appName);
connection
navigator.connection.downlink
appUserAgent:
// Identified the browser.
// plugin
// mimeTypes
// To check service worker is registered or not-
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register(window.location.href + 'service-worker.js')
// navigator.serviceWorker.register('worker-basic.min.js');
.then(function () {
console.log('sw registered');
})
.catch(function (e) {
console.log('sw-error:', e);
});
} else {
console.error('this browser does not support service workers');
}
// share
// navigator.share will only work on web apps with HTTPS and not HTTP. web share API only working in android chrome.
let newVariable;
newVariable = window.navigator;
if (newVariable.share) {
newVariable.share({
title: 'Basic',
text: 'hello world',
url: 'https://developers.google.com/web',
})
.then(() => console.log('Successful share'))
.catch((error) => console.log('Error sharing', error));
}