我有下面的JavaScript代码,用来在脸书和推特上分享这个链接。
<script type="text/javascript">
function show_fb(id)
{
alert('http://www.facebook.com/sharer.php?u=
http://devel.testingsite.biz/testxxxxx.php?cmd=profile&id='+id+'');
u=location.href;
t=document.title;window.open('http://www.facebook.com/sharer.php?u={https_server}testxxxxx.php?cmd=profile&id='+id+'','sharer','toolbar=0,status=0,width=626,height=436');
return false;
}
</script>在HTML端,它是这样显示的:
<li><a href="javascript:void(0)" onclick="show_fb({uid});" class="icon_h3"></a></li>函数正在工作,它显示了共享窗口,但我要共享的链接是没有id的链接
http://devel.testingsite.biz/testxxxxx.php?cmd=profile
但是,当在alert函数中打印相同的链接时,会显示.I需要生成以下链接的id(如下所示)。
http://devel.testingsite.biz/testxxxxx.php?cmd=profile&id=645
我的函数中有什么错误吗?
发布于 2012-04-13 12:34:59
你能试试这个吗?
<script type="text/javascript">
function show_fb(id)
{
alert("http://www.facebook.com/sharer.php?u=
http://devel.testingsite.biz/testxxxxx.php?cmd=profile&id='+id+'");
u=location.href;
t=document.title;
window.open("http://www.facebook.com/sharer.php?u={https_server}testxxxxx.php?cmd=profile&id='+id+'','sharer','toolbar=0,status=0,width=626,height=436");
return false;
}
</script>https://stackoverflow.com/questions/10135229
复制相似问题