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 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂