Share Article Code for Link

I have this code for Facebook, Twitter, and LinkedIn but what do I add for just a link for them to copy ?

<script>
    $(document).ready(function () {
        let title = document.title;
        let url = window.location.href;
        $('[data-share-facebook').attr('href', 'https://www.facebook.com/sharer/sharer.php?u=' + url + '%2F&title=' + title + '%3F');
        $('[data-share-facebook').attr('target', '_blank');

        $('[data-share-twitter').attr('href', 'https://twitter.com/share?url=' + url + '%2F&title=' + title + '&summary=');
        $('[data-share-twitter').attr('target', '_blank');

        $('[data-share-linkedin').attr('href', 'https://www.linkedin.com/shareArticle?mini=true&url=' + url + '%2F&title=' + title + '&summary=');
        $('[data-share-linkedin').attr('target', '_blank');
        
    });
</script>

link


Read only - Webflow - Midway ISD

I actually need to change that link to a mail icon and when visitors click the icon, it will open their email and have the link to the blog post in the body of the email.

I have a custom attribute of data-share-link=“true”

I just do not know what code to use. I tried the following but it is not working

     $('[data-share-link').attr('href', 'mailto:/shareArticle?mini=true&url=' + url + '%2F&title=' + title + '&summary=');
        $('[data-share-link').attr('target', '_blank');

The mailto protocol is e.g.;

mailto:email@company.com?subject=something&body=more-stuff

Here because you don’t know the email, you can leave it blank, e.g.

mailto:?body=YOUR-ARTICLE-LINK

Important, make sure your link is a full URL, not a relative page, and also make sure that it’s URL-encoded.

just adding link to article (has been updated this year) with form that will obfuscate email. Worth to read.

Protecting mailto links < JavaScript | The Art of Web.

1 Like

Thank you very much for your help.