Skip to content

Instantly share code, notes, and snippets.

@apnerve

apnerve/like

Created Dec 11, 2011
Embed
What would you like to do?
Facebook like bookmarklet
javascript:(function(){try{var%20url=encodeURIComponent(location.href);var%20ifr=document.createElement('iframe');ifr.style.position='absolute';ifr.style.top=10+'px';ifr.style.left=10+'px';ifr.style.width=450+'px';ifr.style.height=100+'px';ifr.style.border='none';ifr.src='http://www.facebook.com/plugins/like.php?href='+url+'&show_faces=true&width=450&action=like&colorscheme=light';ifr.scrolling='no';ifr.frameborder=0;document.getElementsByTagName('body')[0].appendChild(ifr);}catch(e){}})();
@apnerve

This comment has been minimized.

Copy link
Owner Author

@apnerve apnerve commented Dec 11, 2011

You can make use of this bookmark-let if you want to 'like' any webpage which doesn't have a 'like' button.

@sengupta

This comment has been minimized.

Copy link

@sengupta sengupta commented Dec 11, 2011

I love this!

A couple of comments though:

  • Is there any way to add a background to the iframe? I couldn't see it the first time I tried it.
  • I see the same bookmarklet also works if you replace "http" with "https". I'm not sure if that is useful.

Thanks for this though. Bookmarklets are what my browser runs on.

@apnerve

This comment has been minimized.

Copy link
Owner Author

@apnerve apnerve commented Dec 11, 2011

Yes. it is.

javascript:(function(){try{var%20url=encodeURIComponent(location.href);var%20ifr=document.createElement('iframe');ifr.style.position='absolute';ifr.style.top=10+'px';ifr.style.left=10+'px';ifr.style.width=450+'px';ifr.style.height=100+'px';ifr.style.border='none';ifr.style.backgroundColor="#fff";ifr.src='http://www.facebook.com/plugins/like.php?href='+url+'&show_faces=true&width=450&action=like&colorscheme=light';ifr.scrolling='no';ifr.frameborder=0;document.getElementsByTagName('body')[0].appendChild(ifr);}catch(e){}})();

This was just a test run to see if the 'like' function works. Would add more styling to it later.

@sengupta

This comment has been minimized.

Copy link

@sengupta sengupta commented Dec 11, 2011

Awesome- I'm forking this then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.