0

How to share the blogger post along with the link of the post using Webshare API or any other?. I want to share my blog post (Entire content) along with the link instead of sharing only post link. As of now I am using Navigator.share () function.

Below is the code.

    <script>
                let shareData = {title: '', text: '', url: '' ,}
                const btn = document.querySelector('#share');
                const resultPara = document.querySelector('.result');
                btn.addEventListener('click', () =>
             {    
                navigator.share(shareData).then(() =>
                resultPara.textContent = 'Data shared successfully' ) .catch((e) = resultPara.textContent = 'Error: ' + e)
             });
       
    </script>

1 Answers1

0

If you really want to share the entire article text, on Blogger blogs you could populate your options object as follows:

options.text = document.querySelector('.post').innerText;
options.url = location.href;

You need to be sure to only show your Share button on pages that have a post on it.

DenverCoder9
  • 2,024
  • 11
  • 32