Created
June 6, 2012 20:21
-
-
Save McKinneyDigital/2884508 to your computer and use it in GitHub Desktop.
Share to Twitter from a link using Javascript
Simple and nice.
Thanks!
Thanks.
Very straightforward
Just a little improvement to easily add other params:
// Opens a pop-up with twitter sharing dialog
var shareURL = "http://twitter.com/share?"; //url base
//params
var params = {
url: "http://google.com",
text: "Replace this with your text",
via: "sometwitterusername",
hashtags: "hashtag1,hashtag2"
}
for(var prop in params) shareURL += '&' + prop + '=' + encodeURIComponent(params[prop]);
window.open(shareURL, '', 'left=0,top=0,width=550,height=450,personalbar=0,toolbar=0,scrollbars=0,resizable=0');
Thanks ! working like a charm !
Thanks a lot!
Hello,
I want to share an image for my site's promotion on twitter so what I have to pass in below code
`var url = "http://google.com";
var text = "Replace this with your text";
window.open('http://twitter.com/share?url='+encodeURIComponent(url)+'&text='+encodeURIComponent(text), '', 'left=0,top=0,width=550,height=450,personalbar=0,toolbar=0,scrollbars=0,resizable=0');
`
Can we share image in this view?
How can we share image? Any solution, please?
How can we share image?
@tassiocaique How can we share image??
How can we close the window after posting the link?
How can we share image?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is great! Thanks for sharing! One question....what do you do when you have commas, quotes, ampersands, etc? They get converted as well and it provides a challenge. Any workaround for that?