我使用使用encodeURIComponent感到困惑傳遞http://
在一個字符串的URL,因爲它是被剝離到URL進行編碼錯誤
http%3A%2F%2F
我試過。(HTTP://)
,但沒有工作,要麼.. 我想要的網址進入這裏:
https://www.facebook.com/sharer/sharer.php?url=
這裏是我的代碼不工作:
$(document).on('click', '.fb', function(e) {
var findfb = $('.fb').parent().parent().parent().find(".zoomy").attr("src");
var facebook_url = 'http://www.facebook.com/sharer.php?url=http://www.site.com/folder1/'+encodeURIComponent(findfb)+
'&title='+encodeURIComponent('title of page');
window.open(facebook_url);
});
encodeURIComponent方法應該打開HTTP://部分爲你貼上什麼。 decodeURIComponent應該不轉換它。你如何將URL傳遞給Facebook分享器API? –
這完全正確。你有什麼問題? – SLaks
我更新了我的源代碼。 – Blynn