How to Update URL for Dynamic URLs

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;

I also tried this but no any effect:

        "url": document.location.href,

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.

stWidget.shareables[0].url = window.location.href;

Need Your Help

Observe for highlight?

events firefox-addon selection xpcom selectionchanged

Is it possible to use nsISelectionController to watch when a a highlight/selection is made?