

GitHub - NascHQ/share-api-polyfill: A polyfill for the sharing that can be used...
source link: https://github.com/NascHQ/share-api-polyfill
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md
Share API Polyfill
This is a polyfill for the Web Share API
that can be used in desktop too, so your users can share in their twitter, facebook, messenger, linkedin, sms, e-mail, print, telegram or whatsapp.
It also supports multilanguage (so far, available in english, spanish and portuguese, and you can help us with that :) ).
This is a very simple, single file import polyfill.
Installing it:
Just import it like so:
<script src="https://naschq.github.io/share-api-polyfill/dist/share-min.js"></script>
Note that we are using the github cdn to load it, you could also save it in your own structure so you can cache it with service workers and have it "close" to your own domain.
Now, it will use the native share panel if it is available (only available on mobile devices) and, if not, it will enable an HTML structure in your page showing options for your users.
Here, check this demo and see the share api polyfill in action.
The Share API
The oficial share api works like this:
navigator.share({ title: 'Web Share API Polyfill', text: 'A polyfill for the Share API. Use it to share in both desktops and mobile devices.', url: location.href }) .then( _ => console.log('Yay, you shared it :)')) .catch( error => console.log('Oh noh! You couldn\'t share it! :\'(\n', error));
But in this case, you can also pass your Facebook App Id
to enable sharing with messenger.
Also, you can pass in a list of hashtags to be used when sharing with twitter.
navigator.share({ title: 'Web Share API Polyfill', text: 'A polyfill for the Share API. Use it to share in both desktops and mobile devices.', url: location.href, fbId: '123456789123456', hashtags: 'javascript,shareAPI,polyfill' }) .then( _ => console.log('Yay, you shared it :)')) .catch( error => console.log('Oh noh! You couldn\'t share it! :\'(\n', error));
It's open source
Yup, it's open source and you can contribute to it :)
Please refer to our CONTRIBUTING.md and help us improve this tool.
Recommend
-
106
create-react-context Polyfill for the proposed React context API Install yarn add create-react-context
-
104
symfony/polyfill-mbstring: This component provides a partial, native PHP implementation for the Mbstring extension. Sk...
-
110
dialog-polyfill.js is a polyfill for <dialog> and <form method="dialog">. Check out some demos! <dialog>...
-
87
README.md
-
39
README.md Symfony Polyfill / Ctype This component provides ctype_* functions to users who run php versions without the ctype extension. More information can be found in the...
-
44
README.md window.fetch polyfill The fetch() function is a Promise-based mechanism for programmatically making web requests in the browser....
-
38
README.md getallheaders PHP getallheaders() polyfill. Compatible with PHP >= 5.3.
-
6
dialog-element-polyfill Lightweight polyfill (2kb) for the dialog element. Ussage <script src="https://cdn.jsdelivr.net/gh/nuxod...
-
6
ES1995 – The Missing JS Polyfill ES1995 is a polyfill for super-modern Javascript that you can write today. What people said about ES1995 Brendan Eich
-
6
<selectmenu> polyfill Based on the proposal open-ui.org/components/selectmenu by Open...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK