开发者

Sharing dynamic (javascript generated) pages on facebook

开发者 https://www.devze.com 2023-02-28 12:26 出处:网络
I have a web app that is completely contolled with javascript. This means there is only one request that renders the full page, everything else is json\'ed to be rendered.

I have a web app that is completely contolled with javascript. This means there is only one request that renders the full page, everything else is json'ed to be rendered.

Facebook share uses opengraph tags in the head to control开发者_开发百科 what text and image to display in the sharing, but my application is a single page, single header, so that I could use only one image for all links on the app.

We are using hashbangs (#!) to control where the user is within the application, but we also have a url rewriter that, when the user hits a URL like

http://domain/action/id

they get sent to (through a redirect header)

http://domain/#!/action/id

So, given this scenario, I want to know if there is a way to share my urls on facebook, and tell facebook to get a different image for each of my URLs.


When facebook-share gets the page, it does not process the javascript in it - but tries to search for the opengraph tags in it. so basically there is no way to share your url's on facebook and have a different picture unless you have your opengraph tags loaded in the response - without javascript. Think of what would you do if you had no javascript at all..

So what you would have to do is to load the opengraph tags in the page before you use javascript.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号