A polyfill for button type=”share”

<button type="share">
  1. This browser supports button type="share". Great! Don’t do anything. Otherwise proceed to level two.
  2. This browser supports the JavaScript Web Share API. Use that API to share the current page URL and title. Otherwise proceed to level three.
  3. Use a mailto: link to prefill an email with the page title as the subject and the URL in the body. Ya basic!
  1. A browser supports button type="share". Currently that’s none because I literally made this shit up yesterday.
  2. A browser supports the JavaScript Web Share API. This is Safari on Mac, Edge on Windows, Safari on iOS, and Chrome, Samsung Internet, and Firefox on Android.
  3. A browser supports neither button type="share" nor the existing JavaScript Web Share API. This is Firefox and Chrome on desktop (and Edge if you’re on a Mac).

--

--

--

A web developer and author living and working in Brighton, England. Everything I post on Medium is a copy — the originals are on my own website, adactio.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Creating a Simple Music Player with JavaScript

React Context in the World of Component Composition

Angular: Multi-Step Form — with Reactive Forms Sorcery

Magic Link Authentication and Route Controls with Supabase and Next.js

A Quick Guide To Stacks In JavaScript

Nestjs & Pino — the one minute setup

IncentiBook: Cookies and Careers

Writing a unit test for an ES module in html-react-parser

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jeremy Keith

Jeremy Keith

A web developer and author living and working in Brighton, England. Everything I post on Medium is a copy — the originals are on my own website, adactio.com

More from Medium

Feature Toggles — Nature inspired design

Recoil.js just got easier with Recoilize

🤷‍♂️Why Safematrix can keep your assets Safe❓❔(Part1)

Process Documentation of Wireframing, Prototyping, User Testing, and Iterating