Demo of Web Share

Thomas Mak wrote at 2019-05-18.


Web Share screenshot

<h1>This is a demo of the web share button</h1>

  Here is an image that you can <a class='web-share' href=''>share the URL</a>:
  <img src="" alt="Place holder image">
let shareButtons = document.querySelectorAll("a.web-share");
for (button of shareButtons) {
  button.addEventListener('click', function(e){
    let href = this.getAttribute('href');
    let alt = this.getAttribute('alt');    
    if (navigator.share) {      
        title: alt,
        url: href

See the Pen Demo of Web Share button by Thomas Seng Hin Mak (@makzan) on CodePen.




no comments yet.

Please login to chat.