Here is my Code of Addthis:
<script type="text/javascript" src="addthis_widget.js"></script>
<script type="text/javascript">
var addthis_config = {
services_expanded: 'facebook, twitter'
}
</script>
<a addthis:services_compact="facebook,twitter" addthis:services_expanded="facebook,twitter" addthis:url="#" class="addthis_button" href="#"><img id="btn_share" name="btn_share" style="cursor:pointer;" src="path to image" alt="Share" /></a>
If I put this Addthis code in simple HTML file and try to run through any server for example in my case I’m using Apache. And try to run from the browser through localhost/myaddthis.html, than its work fine (show the proper popup to share specific link to facebook and twitter).
But the problem is: when I try to run simple html file direct inside browser, then its just show the image, don’t show the proper addthis share popup.
It’s just a simple .HTML file (there is no server side code inside the file), than why its not running without server.
I want to use this code without server. How I do that?
You’re probably viewing your pages by opening them as local files rather than loading them from a web server. So instead of the URL of the page in your browser starting with http:// it starts with C:\ or file://
Here’s what the AddThis buttons look like when viewed via http:// – https://i.stack.imgur.com/hdiiV.png
And here’s the same file viewed using file:// – https://i.stack.imgur.com/m7re9.png
We currently are using protocol-free URLs in our code – ones that start with // instead of http:// or https:// – to make sure our SSL implementations are cross compatible without extra work. However, if you’re loading the test page with the file:// protocol it causes the CSS and other JavaScript files not to load, since it’s looking for them on your local machine rather than our web servers.
I’ve submitted a ticket to our developers to fix this for people previewing pages using their file system rather than a web server, but until they can get that implemented you should either understand that the buttons won’t show up if using the file:// protocol or use a web server in order to test how your sites display in browsers.