nav_share_polyfill

1.0.0 • Public • Published

A polyfill for navigator.share()

Demo: test here


A good navigator.share polyfill. Looks like native. It's size is about 4kb. Eazy to use, free and open-source.
Usage:
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())

Package Sidebar

Install

npm i nav_share_polyfill

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

18.6 kB

Total Files

4

Last publish

Collaborators

  • isaqueks