Creating a Popup Dialog in an IFrame
From Facebook Developer Wiki
If you've made an iframe-based application (where your application's canvas page is actually an iframe rendering content from your servers), you can create popup dialogs through the following JavaScript and FBJS calls. This way, you can create Feed dialogs through JavaScript, and not use FBML.
Next, include the following snippet with your code (which you should put in place of <YOUR CODE HERE>). You need to reference:
- Version 0.4 of the Facebook JavaScript Client Library
- Your application's API key (not the application secret)
- A site relative URL to the cross-domain communications channel file, xd_receiver.htm (for more information, see Cross Domain Communication Channel)
<script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">
FB_RequireFeatures(["XFBML"], function(){
FB.Facebook.init(<application API key>, <site relative URL to xd_receiver.htm>, null);
<YOUR CODE HERE>
});
</script>
You call the following functions:
- FB.Connect.showFeedDialog -- This call renders the Feed dialog in an iframe app or a website using Facebook Connect.
- FB.Connect.showAddSectionButton -- This is the JavaScript version of the fb:add-section-button FBML tag, which lets you prompt your application's users to add a condensed profile box or an application info section to their profiles.
Note: The target_id parameter allows for the Feed dialog to publish to one friend's feed. In order for an iframe application to publish Feed stories to multiple friends' Feeds, use the multiFeedStory form within fb:serverfbml tags.
[edit] See Also
- Facebook.showFeedDialog, for FBML pages.
