Skip to content

Instantly share code, notes, and snippets.

@ophentis
Created November 28, 2012 04:05
Show Gist options
  • Save ophentis/4158967 to your computer and use it in GitHub Desktop.
Save ophentis/4158967 to your computer and use it in GitHub Desktop.
customized twitter share by javascript without twitter api
//@requires jQuery to find width and height of window and creating querystring
var href = 'http://twitter.com/share';
var option = {
url: 'your location',
text: 'your text'
};
var width = 575,
height = 400,
left = ($(window).width() - width) / 2,
top = ($(window).height() - height) / 2,
url = $(this).attr('href'),
opts = 'status=1'
+ ',width=' + width
+ ',height=' + height
+ ',top=' + top
+ ',left=' + left;
window.open(href + '?' + $.param(option), 'Twitter Share', opts);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment