最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Detect when user "clicks" the Facebook like button - Stack Overflow

programmeradmin1浏览0评论

Is it possible to detect when someone clicks the like button "and before the like action really occurs", i.e. same as onSubmit JS event, it detects when the user submit the form before it even get submitted, giving the ability to process/run some code before it do so.

Usage:
I am trying to implement a Web 2.0 page where all the action happens in one page, so depending on the user actions the content of the page would change "But not the meta"

So my question is, can I detect when the user "clicks" the like button so I can "load" the meta of the current page before the like action really happens?

P.S, I do know that it's not a big deal to load the meta as it's less than 1KB and won't have any effect, however I am just curious if there is any way/ work around to do so.

Is it possible to detect when someone clicks the like button "and before the like action really occurs", i.e. same as onSubmit JS event, it detects when the user submit the form before it even get submitted, giving the ability to process/run some code before it do so.

Usage:
I am trying to implement a Web 2.0 page where all the action happens in one page, so depending on the user actions the content of the page would change "But not the meta"

So my question is, can I detect when the user "clicks" the like button so I can "load" the meta of the current page before the like action really happens?

P.S, I do know that it's not a big deal to load the meta as it's less than 1KB and won't have any effect, however I am just curious if there is any way/ work around to do so.

Share Improve this question edited Apr 1, 2021 at 14:49 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Aug 29, 2011 at 20:28 Mohammed IbrahimMohammed Ibrahim 5701 gold badge5 silver badges16 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

You can subscribe to an event that will notify you when the user likes something - however this will fire after the action. This is documented at: http://developers.facebook./docs/reference/javascript/FB.Event.subscribe/

An example would be:

FB.Event.subscribe('edge.create', function(response) { alert('You liked the URL: ' + response); /* check the response here to see if it's your URL */ });

You could attempt to intercept the action but why would you want to wait to add the meta? Do you mean the open graph headers? Facebook scrapes these every 24-hours, not for each unique like event. Also it would most likely be against Facebook's terms to intercept/alter the like action, as you'd be interfering with their established and expected guidelines.

发布评论

评论列表(0)

  1. 暂无评论