0

Early each morning, our Executive has requested an email that contains all the Breaking News from the night before. We store this in our db but he has had connectivity issues lately so he has asked that we copy everything into an email for him.

Also specifically asked that we use anchors so he can navigate in the email because some of the articles are super long.

We are not allowed to send email from our server so I had to instead setup a page that does the query, assembles it and we just copy/paste right into an email.

Problem is, once the HTML is in the email, all the links point back to my page where the original js created it. I need the links to all just point inside the email page.

I do it like below

if (data.count > 0) {

    $.each(articles, function (i, s) {
        titles.push('<a href=\"#anchor-' + i + '\">' + s.title + '</a><br />');
        body.push('<a name=\"anchor-' + i + '\"></a>'
                    + '<p><strong>' + s.title + '</strong><br />'
                    + s.body + '</p>'
                    + '<p>[<a href=\"#top\">back to top</a>]</p>');
    });
    $("#" + tag).html(titles.join(''));

    $("#" + tag + 'Text').html(body.join(''));

}

 <section>
    <a name="top"></a>
    <div id="Transcripts"></div>
    <p></p>
    <div id="TranscriptsText"></div>
 </section> 

 <button class="btn btn-default btn-sm" onclick="CopyToClipboard('Email')" id="btnCopy"></button>

<script>

    function CopyToClipboard(containerid) {
        if (document.selection) {
            var range = document.body.createTextRange();
            range.moveToElementText(document.getElementById(containerid));
            range.select().createTextRange();
            document.execCommand("Copy");

        } else if (window.getSelection) {
            var range = document.createRange();
            range.selectNode(document.getElementById(containerid));
            window.getSelection().addRange(range);
            document.execCommand("Copy");
            //alert("text copied")
        }
    }

</script>
Tim Cadieux
  • 447
  • 9
  • 21

0 Answers0