JSFiddle - React, Tailwind, and code Playground
HTML
<a id="shareFacebook" class="btn btn-default" style="position: relative;top: 50px;">COMPARTILHAR AGORA</a>
JavaScript
$('#shareFacebook').on('click', function(e) {
e.preventDefault();
FB.ui({
display: 'popup',
method: 'share',
href: "www.google.com",
},
/** our callback **/
function(response) {
if (response && response.post_id) {
/** the user shared the content on their Facebook, go ahead and continue to download **/
//$('#ShareToDownload').fadeOut(function(){ $('#downloadSection').fadeIn() });
alert("Its Shared");
} else {
/** the cancelled the share process, do something, for example **/
alert('Please share this page to download this file');
}
});
});
window.fbAsyncInit = function() {
FB.init({
appId : '1072354449442323',
xfbml : true,
version : 'v2.8'
});
FB.AppEvents.logPageView();
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));