51 lines
1.4 KiB
HTML
51 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Share Functionality Example</title>
|
|
<style>
|
|
body {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
height: 100vh;
|
|
background-color: #f0f0f0;
|
|
font-family: Arial, sans-serif;
|
|
}
|
|
button {
|
|
padding: 15px 30px;
|
|
font-size: 16px;
|
|
color: white;
|
|
background-color: #007bff;
|
|
border: none;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
}
|
|
button:hover {
|
|
background-color: #0056b3;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<button id="shareButton">Share This Page</button>
|
|
|
|
<script>
|
|
document.getElementById('shareButton').addEventListener('click', function() {
|
|
if (navigator.share) {
|
|
navigator.share({
|
|
title: 'Check out this page!',
|
|
text: 'This is a simple example of a share functionality.',
|
|
url: window.location.href
|
|
})
|
|
.then(() => console.log('Share successful'))
|
|
.catch((error) => console.error('Error sharing:', error));
|
|
} else {
|
|
alert('Share not supported on this browser.');
|
|
}
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|