How to update the twitter share button URL when changing the window URL with pushState


Hey I initialize the tweet button at the beginning on my app, after user interaction the URL is updated using HTML5 pushState, but the twitter button is still sharing the previous URL from when it was initialized. How do I update the URL that twitter uses?


Try calling twttr.widgets.load() after using pushState - that may reinitialize the button.


No it doesnt. Had to remove the iframe then add the anchor tag back with the updated data-url attribute, then call twttr.widgets.load again. Bit hacky for something so trivial.



My Tweet share-button does not update the text/url inside the share box as it should. I think that I should use the twttr.widgets.load(); function in my code…but i’m unsure of where I need to put it in my code. I am sure that the function should reside inside the . I have tried this but nothing updated…however I am unconvinced that the method I have implemented is wrong but may have implemented the code with incorrect syntax. could i get some feedback on this please!


Please share the code you’re using to embed the button and that will help us identify any errors. Thanks!