Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm getting confused passing the http:// in a string to the url as it is being stripped to

http%3A%2F%2F 

I tried.. using the encodeURIComponent(http://)

but that didn't work either.. I'm trying to pass the url into here:

https://www.facebook.com/sharer/sharer.php?url=

Here is my code that isn't working:

$(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); 


});
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
206 views
Welcome To Ask or Share your Answers For Others

1 Answer

Just do it as simple as:

var facebook_url = 'http://www.facebook.com/sharer.php?url=' + encodeURIComponent('http://www.site.com/folder1/' + findfb +'&title=' + 'title of page');

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...