Javascript "E;%2F“;将更改为/&引用;什么时候;例如;
当“喜欢”下面写的url时,就会出现问题 “编辑配置文件>活动和兴趣>您喜欢的其他页面”中的链接url为 …/aaa/bbb/ccc/xxx%2Fxxx/ 但是用户墙中的链接url是 …/aaa/bbb/ccc/xxx/xxx/ 在用户墙中使用正确的链接应该怎么做 Javascript源代码:Javascript "E;%2F“;将更改为/&引用;什么时候;例如;,javascript,facebook-like,Javascript,Facebook Like,当“喜欢”下面写的url时,就会出现问题 “编辑配置文件>活动和兴趣>您喜欢的其他页面”中的链接url为 …/aaa/bbb/ccc/xxx%2Fxxx/ 但是用户墙中的链接url是 …/aaa/bbb/ccc/xxx/xxx/ 在用户墙中使用正确的链接应该怎么做 Javascript源代码: function getFacebookUrl() { var thisPath = location.pathname; var fbUrl; var host = locat
function getFacebookUrl() {
var thisPath = location.pathname;
var fbUrl;
var host = location.host;
var regex = new RegExp("\/([^\/]+)\/([^\/]+)\/([^\/]+)\/([^\/]+)\/");
if (thisPath.match(regex)) {
thisPath = "/" + RegExp.$1 + "/" + RegExp.$2 + "/" + RegExp.$3 + "/" + encodeURIComponent(RegExp.$4) + "/";
}
fbUrl = location.protocol + "//" + host + thisPath;
return encodeURIComponent(fbUrl);
}
var url = getFacebookUrl();
document.write('<iframe src="//www.facebook.com/plugins/like.php?href=' + url + '&send=false&layout=box_count&width=450&show_faces=true&action=like&colorscheme=light&font&height=65" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:74px; height:65px;" allowTransparency="true"></iframe>');
函数getFacebookUrl(){
var thisPath=location.pathname;
var-fbUrl;
var host=location.host;
var regex=new RegExp(“\/([^\/]+)\/([^\/]+)\/([^\/]+)\/([^\/]+)\/”;
if(thisPath.match(regex)){
thisPath=“/”+RegExp.$1+“/”+RegExp.$2+“/”+RegExp.$3+“/”+encodeURIComponent(RegExp.$4)+“/”;
}
fbUrl=location.protocol+“/”+主机+此路径;
返回组件(fbUrl);
}
var url=getFacebookUrl();
文件。写(“”);
怎么样
var url = unescape('http://example.com/aaa/bbb/ccc/xxx%2Fxxx/');
谢谢你的回答。但结果是一样的。@YujiTamai我的答案将“%2F”替换为“/”,从而创建了一个“正确”的url。这不是你想要的吗?您想要相反的结果吗?参数除以“/”。第四个参数必须是“xxx/xxx”的值。进展了一段时间。这似乎是“og:url”值的问题。当“og:url”的“xxx%2Fxxx”被编码时,它成功了。成功的“og:url”为“”