Yesterday afternoon, while adding a social bookmarking tool from ShareThis, we came across the following JavaScript error that just wouldn’t go away, even though we were using the same code snippet as is shown on the ShareThis example pages.
SHARETHIS is null
I don’t know how many different things we tried to get it to work, but safe to say we wasted more than enough time for what it was worth!
The solution? For some reason, this tool barfs when running from localhost if you are not using the actual IP address. In our case, we were running the site off http://localhost/sitename. ShareThis will only work locally if you use the IP address for localhost, like so: http://127.0.0.1/sitename.
This was a wierd one and really there is no reason why it shouldn’t work with localhost. Hopefully those ShareThis guys will GetThis and save future developers a whole lot of headaches!
Remote JavaScript will not execute on a page loaded through “localhost”. It’s a security restriction built into browsers since “localhost” has a different security sandbox than a real web server. When developing, a way around this is to add an entry to your HOSTS file that includes a fake DNS entry that points to 127.0.0.1
Hi, sorry for the inconvenience,
Remote JavaScript will not execute on a page loaded through “localhost”. It’s a security restriction built into browsers since “localhost” has a different security sandbox than a real web server.
We are currently redesigning our website and this is something we will be adding to our documentation.
If you ever have any more issues with ShareThis, feel free to contact me at sragan at sharethis dot com
Thanks,
Steve R
@steversb