[英]Dynamic Twitter Share button
這是提取當前頁面的標題和URL並在Twitter上共享的代碼。
我需要在標題文本后添加@TwitterHandle的幫助,但無法使其正常工作,因此在共享時會讀取:“標題URL @TwitterHandle”
感謝您的快速輸入。 謝謝。
<script>
function tweetCurrentPage()
{ window.open("https://twitter.com/share?url="+escape(window.location.href)+"&text="+document.title, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');return false; }
</script>
<a class="tweet" href="javascript:tweetCurrentPage()" target="_blank" alt="Tweet this page"><span>Tweet</span></a>
Twitter句柄需要作為text
URL參數的一部分傳遞。 請參考以下代碼片段。
<script>
var twitterHandle = 'sarbbottam';
function tweetCurrentPage() {
window.open('https://twitter.com/share?url='+escape(window.location.href)+'&text='+document.title + ' via @' + twitterHandle, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');
return false;
}
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.