-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
43 lines (36 loc) · 974 Bytes
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title>Web Share Testing</title>
</head>
<body>
<h3>Share</h3>
<button id="test-web-share">
Share
</button>
<script>
function directShare() {
if (navigator.share !== undefined) {
navigator.share({
title: 'My awesome post!',
text: 'This post may or may not contain the answer to the universe',
url: window.location.href
}).then(() => {
//window.alert('Thanks for sharing!');
})
.catch(err => {
//window.alert(`Couldn't share because of`, err);
});
}
}
document.querySelector('#test-web-share').addEventListener('click', () => {
directShare()
});
function codeAddress() {
alert("auto");
directShare();
}
window.onload = codeAddress;
</script>
</body>
</html>