Created
March 13, 2021 22:40
-
-
Save alechash/2c634d9c0775045c742c789e23650100 to your computer and use it in GitHub Desktop.
javascript enabled navigator share
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
.hidden { | |
display: none; | |
} | |
</style> | |
<button id="_share" class="hidden">share</button> | |
<script> | |
if (navigator.share) { | |
document.getElementById('_share').classList.remove('hidden'); | |
document.getElementById('_share').addEventListener('click', function() { | |
navigator.share({ | |
title: 'title', | |
text: 'message', | |
url: 'https://some.url' | |
}); | |
return false; | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment