Custom Tweet Button without URL?


#1

Hello! I’m creating a custom tweet button. Sometimes the URL will be inside of the “message”, so I don’t want it appended at the end of the tweet (the only behavior I can get from Twitter).

IE:
Hey, go to http://example.com for details!

To accomplish this, I open a window with JS and set url to false:

function tweet (message) {
	window.open('https://twitter.com/share?text='+encodeURIComponent(message)+'&url=false', 'Tweet');
}

In most cases this works fine. Sometimes, though, the word “False” gets appended to the end of the tweet. I haven’t been able to recreate this myself but I have seen it on many tweets from my site.

Is there a guaranteed way to do this?
https://dev.twitter.com/web/tweet-button says that if you don’t include any url, it will use the url of the page (not even the right URL, and appended at the end).

Tweet button with NO URL in the tweet? this post says to just set the url to something incorrect, like http://wrong but I think showing false is better than possibly showing a strange link…

Are tweets not supposed to contain a link in the middle of the message? Are they not supposed to be tweeted without a URL at the end?

Any insight appreciated. Thanks.


#2

Hey, you can use the Twitter share intent as follows:

function tweet(message) {
    window.open('https://twitter.com/intent/tweet?text=' + encodeURIComponent(message), 'Tweet');

Just omit the URL all together.


#3

Thanks @ePirat that appears to be the ticket. I wonder why url was not always optional like this.


#4