To minimize the threat of cross-site scripting (XSS) attacks, Facebook implemented its own JavaScript for developers who really want, or need, to use JavaScript in their applications. Facebook removes much of the JavaScript you can add to your application, but by using Facebook JavaScript (FBJS) you can still enrich the user’s experience. Facebook formally released FBJS 1.0 in September 2007. The following is a quick example of how you can provide a modal dialog box to your users:

<a href="#" onclick="new Dialog().showMessage('Dialog', 'This is the help message for this link');return false">Show Dialog Box</a>

When processed through the Facebook platform, a user will be shown the model dialog box as shown in the figure after clicking the Show Dialog Box hyperlink. Not bad for a single line of code!


0 comments