Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 934
ObiWanKobi Avatar asked Feb 14 '23 08:02

ObiWanKobi


1 Answers

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.

like image 186
CBroe Avatar answered Feb 16 '23 03:02

CBroe