icanCreate
(Robert Pryor)
November 14, 2022, 5:08pm
1
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>
Read only - Webflow - Midway ISD
icanCreate
(Robert Pryor)
October 2, 2023, 7:43pm
2
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');
memetican
(Michael Wells)
October 2, 2023, 9:01pm
3
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.
The encodeURI() function encodes a URI by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two...
Stan
(justAnotherDeveloper)
October 2, 2023, 9:36pm
4
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
icanCreate
(Robert Pryor)
October 3, 2023, 1:55pm
5
Thank you very much for your help.