How to share via twitter?

How to share via twitter?
0

#1

Hi,

How do I create a function (without jquery) called tweetIt in JS that can share information from my page to Tweeter ?

function tweetIt() {
// some code here that can share information to twitter
}

My HTML code is like this:

button type=“button” class=“btn btn-primary btn-lg” onclick=“tweetIt( )”>Share Movie</button

If visitor click the button called Share Movie, he can share the information about that particular movie to twitter.

I already read documentation about Tweet Web Intent but still can’t understand how to do it


#2

You can use window.open() and use Twitter Web Intent URL with it.


#3

Thanks Kev @kevcomedia, it works now

function tweetIt() {
urlFullTmdb = urlTmdb + tmdbId;
urlFullPoster = urlImage + poster_path;
var url = “https://twitter.com/intent/tweet?text=” + title + " " + urlFullTmdb + " " + urlFullPoster;
window.open(url, ‘_blank’);
}