Share this on Mastodon

Wednesday, December 21st, 2022

We have started to get requests to add a “Share on Mastodon” link next to the ones for Twitter, Facebook, etc.

This is a great sign, but every example I found was overly complicated and utilized modal windows and 3rd party JavaScript libraries. These options are very customizable, but maybe you want something a bit simpler. Here is an inline, vanilla JS prompt option:

Example: Share this post on Mastodon

<a href="#" target="_blank" onclick="let m=prompt('Select your instance:','mastodon.social');if(m){this.href='https://'+m+'/share?text=YOUR TEXT HERE'}else{return false;}">Share</a>

Leave a Reply

You know you want to...