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


#1

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?


#2

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


#3

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.


#4

Hi,

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!


#5

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


#6

#7