How to fix problems with Blogger and the AddThis widget
I have using Blogger as my blogging platform for over a year and a half and I had implemented the AddThis bookmarking widget within each post. I recently upgraded to the new drop-down widget. Suddenly, I began to see strange things happen to the layout of certain blog posts.
As it turns out, any post with an apostrophe or single quote within the title causes a problem with the AddThis Javascript. Basically, the title of a post is stored as a Javascript string variable. If there is an apostrophe or single quote in the middle of the variable, it generates an error related to unterminated strings. Unfortunately, it is not so uncommon to want to use apostrophes.
Luckily, it is easy to fix this by adding one line of code to the Javascript supplied by AddThis.
This is the way the code looks when I get it from AddThis (I have added some carriage returns to enhance readability):
addthis_url='<data:post.url/>';
addthis_title='<data:post.title/>';
addthis_pub='traderadaroperator';
First, change the single quotes around '<data:post.title/>' to double quotes as follows:
addthis_title="<data:post.title/>";
Then add the following line of code:
addthis_title=addthis_title.replace(/\'/g,'');
This approach removes the apostrophe in the title string.
This is not a perfect solution, but it will prevent your titles from being cut off when bookmarking. And most importantly, it won't cause any problems with your page layout. Just be sure not t0 use any double quotes in your blog titles.
You, my friend, just helped me out a GREAT deal. Many many thanks!!!