简体   繁体   English

Facebook共享按钮/history.pushstate/错误的网址

[英]Facebook share button / history.pushstate / wrong url

I am using the facebook like/share button 我正在使用Facebook的“赞/分享”按钮

https://developers.facebook.com/docs/plugins/like-button/ https://developers.facebook.com/docs/plugins/like-button/

to share the current url/page. 共享当前的URL /页面。

Furthermore my urls are created by using the javascript history.push function to modify the url. 此外,我的网址是通过使用javascript history.push函数来修改网址而创建的。

    history.pushState("", "","/123");

So in the beginning my url is "example.com" afer a few seconds the url is modyfied and the new url is like "example.com/123". 因此,在开始时,我的网址是“ example.com”,几秒钟后便对该网址进行了修改,新的网址类似于“ example.com/123”。

The problem is that example.com is shared instead of example.com/123. 问题在于example.com是共享的,而不是example.com/123。 Is there a way to share the new url? 有没有共享新网址的方法?

Thank you 谢谢

Simply updating the data-href attribute on the button will do nothing – it has already been parsed, and “no one cares” any more about what attributes you might change afterwards. 仅更新按钮上的data-href属性将无济于事–它已经被解析,并且“没人在乎”之后您可能会更改的属性。

You will have to remove the button from the document, replace it with a new one – and then call FB.XFBML.parse to get the new button parsed. 您将必须从文档中删除按钮,将其替换为新按钮-然后调用FB.XFBML.parse来解析新按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM