Monday, April 18, 2011

Disguising a Facebook ‘Like’ link

facebook like buttonThe Facebook Like button allows people to share interesting sites they find, with their friends on Facebook. You can place a Like button on any web page and when a user clicks on it, a story appears in the user’s friends’ News Feed with a link back to your website.


Using some clever CSS, you can disguise the Like button to look like something else and trick people to click on the button ;)


.


Update: As a commenter pointed out. This does not work in Internet Explorer because it lacks support for pointer-events. It does work in Firefox, Chrome and Safari.


In the example button below, I’ve disguised the Like button to look like a button that might be used to move between different pages. If you click on it, you’ll be Liking my blog.


(If you don’t see the custom Like button above, go to the Facebook Like test page)


The result of clicking on the above customised Like button is a post going out to all my friends on Facebook letting them know I like http://www.esrun.co.uk


facebook like result


As yet, I haven’t found a way to redirect a user after they click, due to browser security policies on third party content loaded in iframes.


This code is ready to rock. Just swap out ‘href=http://www.esrun.co.uk’ with your own URL and replace the background URL for #fake_facebook_button in the CSS.


In the example below, I’ve again disguised the Like button. This time, when you click on it, not only will you be liking esrun.co.uk but you’ll also be redirected to the next page (for example sake, it redirects to Google).


Note: I’ve placed the sample button inside an iframe so you don’t get taken off this blog post. If you want to see it in use on a regular page then go direct to the Facebook XFBML Like test page


This code is ready to rock n’ roll. Just swap out fb:like href=”http://www.esrun.co.uk/blog/disguising-a-facebook-like-link/” with your own URL and replace the background URL for #fake_facebook_button in the CSS.


NOTE: Unlike the iframe method, with XFBML, if you want to capture and redirect the user when they click on the Like button then the domain where the button is hosted and the URL that the user is Liking must match.


For example I can put the Like button within this post and have people Like any page on esrun.co.uk but couldn’t make them Like a page on onlinehoster.com


There are also legitimate uses of the code above.


For example, if you operated an online store, you could offer a discount during the checkout process if the user ‘Likes’ your website. Instead of redirecting after the user clicks the button(as above), you’d fill in the discount box with your special code.


Another viral example would be making the Like button look like a play button below a new movie trailer. When the user clicks on the button, you’ll start the trailer (instead of redirecting the user, as above). Hell, you could even just use the real button instead of customising it and be upfront by telling the user that they need to click on it before you let them watch the trailer.

No comments:

Post a Comment