Created
May 29, 2020 14:16
-
-
Save camaleaun/209fb1aa732e2bc794f68531f4bc5266 to your computer and use it in GitHub Desktop.
Native sharing
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
window.addEventListener( 'load', () => { | |
document.querySelectorAll( '.sharing-anchor' ).forEach( ( anchor ) => { | |
anchor.addEventListener( 'click', () => { | |
if ( undefined !== navigator.share ) { | |
navigator.share( { | |
title: document.querySelector( 'meta[property="og:title"]' ).content, | |
text: document.querySelector( 'meta[property="og:description"]' ).content, | |
url: document.querySelector( 'meta[property="og:url"]' ).content, | |
} ) | |
} | |
} ); | |
} ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment