16 Jun
Posted by Mike as Bugs, JavaScript, Web Development
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!
2 Responses
Steve R
January 25th, 2010 at 12:30 pm
1Hi, 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
paul
January 26th, 2010 at 10:06 am
2Remote 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
RSS feed for comments on this post · TrackBack URI
Leave a reply
Subscribe to RSS Feed
Categories
Follow me on Twitter
Recent Posts
Disclaimer
Everything posted on this blog is my personal opinion and does not necessarily represent the views of my employer or its clients.