1.0.0 • Published 4 years ago
nav_share_polyfill v1.0.0
A polyfill for navigator.share()
Demo: test here
var data = {
title: 'navigator.share() polyfill',
text: 'A polyfill for navigator.share()',
url: location.href,
}
navigator.share(data)
.then(function() {
alert('You shared it!')
})
.catch(function(e) {
alert('Error');
});
Don't forgget to include the script:
https://isaqueks.github.io/nav_share_polyfill/navigator.share.js
OR (minified)
https://isaqueks.github.io/nav_share_polyfill/navigator.share.min.js
If you want to force the polyfill (even if the browser supports navigator.share()), insert this code (before the main script):
window.FORCE_SHARE_POLYFILL = true;
Works for mobile and desktop (most desktop browsers doesn't support native navigator.share())
1.0.0
4 years ago