I currently have this code from one of the solutions provided, but it doesn't work
<a href="javascript:fbshareCurrentPage()" target="_blank" alt="Share on Facebook">Facebook</a>
the script
<script language="javascript">
function fbshareCurrentPage()
{window.open("https://www.facebook.com/sharer/sharer.php?u="+escape(window.location.href)+"&t="+document.title, '<?php echo $artData["title"]?>',
'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');
return false; }
</script>
Your code is a little wrong here and there. Please see below. NB I would store title into invisible div container as attribute (if it does not contain HTML):
<div id="some_title" data-text="<?php echo $artData["title"];?>"></div>
<script type="text/javascript">
function fbshareCurrentPage() {
var title = $('#some_title').attr('data-text');
window.open("https://www.facebook.com/sharer/sharer.php?u="+escape(window.location.href)+"&t="+title, title, "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600");
}
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.