ObiWanKobi
ObiWanKobi

Reputation: 193

Twitter share button without the twitter icon, just the sharing

I want to embed the twitter share option and the code I get is the javascript as well as this link to share:

<a href="https://twitter.com/share" class="twitter-share-button" data-text="Check out this link please" data-via="ObiWanKobi" data-related="User">Tweet</a>

I want the data text and all that to show BUT I want to use my own custom icon and not the twitter icon. So I took away the class="twitter-share-button" because that is what displays this button but once I do that then the data-text is lost and it just shares the link. How does one hack this to show a custom icon?

Your help = greatly appreciated

Upvotes: 4

Views: 2805

Answers (1)

C3roe
C3roe

Reputation: 96417

Simplest way to do this is by not using their JavaScript at all, and simply building the share URL yourself:

http://twitter.com/share?text={…}&url={…}

Don’t forget to URL-encode parameter values you put in there properly.

You might want to add a target="_blank" to the link to open this in a new window/tab, or even add window.open to optionally open it in a popup with a predefined width and height.

Upvotes: 8

Related Questions