0
我有五個Facebook,Twitter,Google Plus,Pinterest和Email的自定義共享圖標。對於每個點擊,我希望他們分享當前的網址。問題是,當shareURL傳遞到窗口URL(例如:https://twitter.com/share?url=shareURL)時,此shareURL不會傳遞到每個社交媒體的對話框中。所以即使認爲它出現在瀏覽器的URL框中,個人社交用戶實際上也沒有分享任何內容。對話框顯示爲空。自定義社交共享:shareUrl傳遞到URL但實際上並未共享shareURL
在我上面的例子中,shareURL = thisURL在我的腳本下面。這裏是我的腳本樣本:
function share_twitter(thisURL){
window.open("https://twitter.com/share?url=" + encodeURIComponent(thisURL));
}
$(document).ready(function(){
thisURL = window.location.protocol + "//" + window.location.host + "/" + window.location.pathname;
$(".twitter").click(function(){
share_twitter(thisURL);
});
我的直覺是,這與全局變量和文件準備函數來完成。不知道該從哪裏出發。