dqst96444 2012-12-03 14:40
浏览 72
已采纳

试图分享到Facebook的链接只分享主要网址

I am new to twitter,facebook etc api's and javascripts.

A similar question might be asked by some one else but please check my question, I guess this question is not a duplicate one.

I am trying to share a url to facebook. Here is my code

<?php $link="www.google.com"> 
    <script>
        function fbs_click() 
        {
        u=location.href;
        t=document.title;
        window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
        return false;
        }
        </script>
        <style>
        html .fb_share_button { display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px;  background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top right; } html .fb_share_button:hover { color:#fff; url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top right; text-decoration:none; }
        </style> 
        <a rel="nofollow" href="http://www.facebook.com/share.php?u=<?php  echo $link;?>" 
        class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-align:center;"></a>
        </div>

But instead of sharing www.google.com it shows main url such as www.mysite.com/facebookshare.php where am i going wrong.

I also tried a simple anchor tag method to share but it disturbs my entire css. exmaple

<a href = "http://www.facebook.com/sharer/sharer.php?u= <?php echo $link;?>">
                    <img src = "http://www.mysite.com/FB_2.png"></a>

Please help me to get the exact url i wish (www.google.com) to be shared to facebook.

Thank you

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 qgcomp混合物线性模型分析的代码出现错误:Model aliasing occurred
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥15 小红薯封设备能解决的来
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答