ShareThis does not seem to have a way to update URL which dynamically changes for html5 history-enabled or ajax-driven sites.
I tried this function to update it but URL remains original:
function initShareThis(){
var el = document.getElementById("lotShareThis");
var target = el.firstChild;
for (var i in stWidget.shareables) {
if (stWidget.shareables[i].element === target) {
stWidget.shareables[i].url = window.location.href;
break;
}
}
el.firstChild.onclick();
}
I also tried this but no any effect:
stWidget.addEntry({
"url": document.location.href,
"title":document.title
});
Any good advice whoever came across this situation?
If you want to try this using AddThis, you can change the title and url by updating the page's title and history like this:
var title = "New Title"
window.document.title = title;
window.history.pushState({path: href}, title, href);
And then you just have to call:
addthis.toolbox('[selector for AddThis buttons]');
This will force all the share buttons to update themselves and use the new title/url specified. If you're still struggling with ShareThis, give this a try.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With