Search code examples
javascriptmobiletwitter

Twitter share link not working on mobile, but it is on desktop


Problem

I have been hard coding links to share a pre-made tweet on Twitter — either in one of the blockquotes or the site in general, which can be found http://bdnsun.ca/veteransdoc. The link to tweet works on desktop, but when I try to share the same links on my iPhone it takes me to the mobile Twitter site with no predone tweet. Is there a work around to this?

Live link: http://bdnsun.ca/veteransdoc

index.html

Contains example of hard coded tweet, which in this case should read “All the streets were blocked off … we knew we was gonna get taken prisoner,” Elmer Cole, PoW survivor: http://bdnsun.ca/veteransdoc

<!-- Blockquote -->
                        <blockquote>
                            <p class="quote__text">“All the streets were blocked off and they wouldn’t evacuate us because we had to stay and keep the Germans off the beach. So we knew we was gonna get taken prisoner.” </p>

                            <div class="quote__person">
                                <p class="quote__name">Elmer Cole</p>
                                <p class="quote__title">South Saskatchewan Regiment</p>
                            </div>

                            <div class="quote__icon">
                                <a href="https://twitter.com/home?status=%E2%80%9CAll%20the%20streets%20were%20blocked%20off%20%E2%80%A6%20we%20knew%20we%20was%20gonna%20get%20taken%20prisoner,%E2%80%9D%20Elmer%20Cole,%20PoW%20survivor%3A%20http%3A//bdnsun.ca/veteransdoc" target="_blank" class="link--twitter"title="Share on Twitter"><span class="tooltip-toggle" data-tooltip="Tweet this quote"><i class="icon-twitter fa fa-twitter" aria-hidden="true"></i></span></a>
                            </div>
                        </blockquote>

Solution

  • It's been a while since Twitter updated its share link. Now there are separate text and url parameters:

    https://twitter.com/intent/tweet?text=text+to+share&url=https://example.org
    

    Pro tip: you could also provide comma-separated tags!

    https://twitter.com/intent/tweet?hashtags=one,two,three&text=&url=