An invalid or illegal string was specified when implementing basic Sharethis code

K Scandrett picture K Scandrett · Jul 23, 2012 · Viewed 18.9k times · Source

I'm trying to implement ShareThis buttons on a page, but cannot get the basic options to work in FF or Chrome, on win 7 or Vista.

Chrome has no plugins. Have disabled FF plugins.

Not sure if the problem is some dumb mistake I'm making, or if it is with ShareIt JS code.

Steps:
1. Signed up
2. Went to http://sharethis.com/publishers/get-sharing-tools
3. Completed the 3 steps (changes: Added Pinterest and removed ShareThis button
4. Created a html file and pasted the code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta http-equiv="Content-Language" content="en-us" />
      <script type="text/javascript">var switchTo5x=true;</script>
      <script type="text/javascript" src="http://w.sharethis.com/button/buttons...; /script>
      <script type="text/javascript">stLight.options({publisher: 'beea8274-700e-4d53-aeff-393478c86a40'}); </script>
   </head>
   <body>
      <span class='st_facebook_large' displayText='Facebook'></span>
      <span class='st_twitter_large' displayText='Tweet'></span>
      <span class='st_linkedin_large' displayText='LinkedIn'></span>
      <span class='st_pinterest_large' displayText='Pinterest'></span>
      <span class='st_email_large' displayText='Email'></span>
   </body>
</html>

On Page load in Firefox I get SyntaxError: An invalid or illegal string was specified. Email button popup just says 'loading....', and 'Pick one or more destinations:' has no options.

Pulled much hair out over this.

Thanks

Answer

K.C.Ashish Kumar picture K.C.Ashish Kumar · Jul 23, 2012

Have you deployed your html file on a server before testing it on a browser. If you are testing the html file directly by placing on your Desktop or some other folder, then it will not work. You need to deploy the html file to a server eg: Tomcat or whichever you are comfortable with.