Rodrigo Gama
Rodrigo Gama

Reputation: 1122

Sharing dynamic (javascript generated) pages on facebook

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.

Upvotes: 3

Views: 1283

Answers (1)

T4u
T4u

Reputation: 291

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.

Upvotes: 2

Related Questions