FBJS/Examples/Hello World

From Facebook Developer Wiki

Jump to: navigation, search

This is a very simple FBJS example to help you get started. This displays a link that changes the color and background when clicked.

<script> <!-- function random_int(lo, hi) { return Math.floor((Math.random() * (hi - lo)) + lo) } function do_colors(obj) { var r = random_int(0, 255), b = random_int(0, 255), g = random_int(0, 255); obj.setStyle({background: 'rgb('+[r, g, b].join(',')+')', color: 'rgb('+[r<128?r+128:r-128, g<128?g+128:g-128, b<128?b+128:b-128].join(',')+')'}); } //--> </script> <a href="#" id="this" onclick="do_colors(this); return false">Hello World!</a>
reference