Social Sharing Starting Point

Most sites want the ability to share pages with the various social platforms. You can of course get AddThis or ShareThis if you want, but sometimes you don’t want all that.

Here is some basic code to get started sharing to Facebook, Twitter and Google+. The javascript in this example will simply open the link in a new popup window which I prefer to opening a new tab.

You will need to set the correct {URL} of course. {MEDIA} is just the “src” of whatever image you want to use as the share image, it is not required. {TITLE} should be obvious.

I included some optional stuff you can use if you need to do some kind of dynamic {MEDIA} replacing, depending on what the user is looking at.

I am using the FontAwesome fonts to display the social media logos, but you can use anything you want. Lastly, I am using jQuery, but this could also be done by putting an onclick event on the link itself (onclick=”javascript:window.open(this.href,”, ‘menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=400,width=600’);return false;”) or whatever method you are most comfortable with.

NOTE: The Pinterest share button here needs some extra love.