网址编码错误 [英] URL being encoded wrong
本文介绍了网址编码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在将http://
字符串中的内容传递给
I'm getting confused passing the http://
in a string to the url as it is being stripped to
http%3A%2F%2F
我尝试了..使用encodeURIComponent(http://)
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);
});
推荐答案
做到这一点就很简单:
var facebook_url = 'http://www.facebook.com/sharer.php?url=' + encodeURIComponent('http://www.site.com/folder1/' + findfb +'&title=' + 'title of page');
这篇关于网址编码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文