Skip to content

Instantly share code, notes, and snippets.

@arnellebalane
Last active April 5, 2017 03:57
Show Gist options
  • Save arnellebalane/9027103671691352f168b42d094f01ce to your computer and use it in GitHub Desktop.
Save arnellebalane/9027103671691352f168b42d094f01ce to your computer and use it in GitHub Desktop.
web share api demo
// progressive enhancement, use it only when it is available
if ('share' in navigator) {
// the object argument to navigator.share() should have at least
// one of the following keys: title, text, url
navigator.share({
title: 'The Web Share API',
text: 'The text that I want to share',
url: 'https://blog.arnellebalane.com/the-web-share-api'
})
.then(() => console.log('Sharing successful'))
.catch((error) => console.log('Sharing failed'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment