0

I am trying to add facebook share button on articles of my blog. so i am considering following link:

https://developers.facebook.com/docs/plugins/share-button

from the above link when i put following javascript code in my website template:

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.4";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-share-button" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button_count"></div>

When i save it then in the line 6:

js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.4";

it is giving follwing error:

"Error parsing XML: The reference to entity "version" must end with the ';' delimiter"

Why it is giving this error as '';' is present at the end of above line???

Thanks in advance.

a Learner
  • 4,944
  • 10
  • 53
  • 89

1 Answers1

1

From this Source:

It looks like something is interpreting your document as XML rather than HTML. XML is much stricter than HTML - one of the rules is that ampersands (&) have a special meaning. They mean "here comes an XML entity", which is a special character. For instance, you can type " to insert ", or > to insert > into your document.

So the solution would be changing the & in src to &amp

js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&amp;version=v2.4";
Community
  • 1
  • 1
Guruprasad J Rao
  • 29,410
  • 14
  • 101
  • 200