简体   繁体   English

当我在Facebook上共享网站链接时显示的Javascript代码

[英]Javascript code shown when I share a link to website on facebook

When sharing some links on facebook(either programatically or manually), javascript code is being shown in the post. 当在Facebook上共享某些链接时(以编程方式或手动方式),该帖子中将显示javascript代码。

Thus my question is more related to how to fix my website, so that, when posting link to facebook, javascript code doesn't show in the facebook post. 因此,我的问题与如何修复我的网站更相关,因此,在发布指向Facebook的链接时,javascript代码不会显示在facebook帖子中。

Forexample try posting this link: http://djuice.com.pk/discounts 例如,尝试发布此链接: http : //djuice.com.pk/discounts

You'l see javascript code(which is present on the shared page) in the facebook post. 您会在Facebook帖子中看到javascript代码(共享页面上显示)。 在此处输入图片说明

You are should set description param for sharing button. 您应该为共享按钮设置description参数。 For example: 例如:

 FB.ui(
      {
       method: 'feed',
       name: 'The Facebook SDK for Javascript',
       caption: 'Bringing Facebook to the desktop and mobile web',
       description: (
          'A small JavaScript library that allows you to harness ' +
          'the power of Facebook, bringing the user\'s identity, ' +
          'social graph and distribution power to your site.'
       ),
       link: 'https://developers.facebook.com/docs/reference/javascript/',
       picture: 'http://www.fbrell.com/public/f8.jpg'
      },
      function(response) {
        if (response && response.post_id) {
          alert('Post was published.');
        } else {
          alert('Post was not published.');
        }
      }
    );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM