Tips and Tricks
Using SWFObject
If you're interested in making your page valid HTML 4 or XHTML, you'll need to use the object tag instead of the embed tag.
This comes with significant hassles, though, so you'll want to use the SWFObject library to do so. As an example, the following embed code:
becomes this:
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("http://embedit.in/IMAFoJ4xKU.swf", "embed_IMAFoJ4xKU", "466", "400", "9.0.28", false, {}, {allowFullScreen: true});
</script>
Be sure to swap in your own ten-character embed identifier in the example code.
Interacting with your Embed
If you are integrating embedit.in into your web application, you probably want some way of controlling document display on your site programmatically. Well, you're in luck — your embed has a robust JavaScript API.
Enabling JavaScript Interaction
JavaScript interaction is easiest to work with when using SWFObject, as outlined above. Once you have that working, add the customize: "yes" flash parameter, the allowDomain: "http://www.yourdomain.com" flash parameter (and of course, substitute the actual domain from which your JavaScript is loaded), the allowScriptAccess: "always" option and specify an ID for the resulting DOM element:
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("http://embedit.in/IMAFoJ4xKU.swf", "embed_IMAFoJ4xKU", "466", "400", "9.0.28", false, {customize: "yes", allowDomain: "http://www.yourdomain.com"}, {allowFullScreen: true, allowScriptAccess: "always"}, {id: 'my_embed_object_id'});
</script>
Calling Methods
Once enabled, interacting with the embed is as easy as calling methods on the DOM object associated with your embed (and determined via the ID you pass to SWFObject). Note: The following code example assumes you are using the Prototype JavaScript framework but it can be easily adapted to another framework or none at all:
Available Methods
The following functionality it currently available:
function print()- Instructs the embed to bring up the system Print dialog, permitting the viewer to print document.
function setBackgroundColor(hex_color)- Sets the background of the player to the color determined by the hex string passed in, such as "0xFF0000" for red
function switchToTab(index)- (Only for embeds displaying multiple files) Makes the tab determined by
index, which is 1-based, the active tab
- (Only for embeds displaying multiple files) Makes the tab determined by
function download()- Instructs the viewer's browser to download the original file represented by the embed
Customizing embedit.in Sitewide
Out of the box, embedit.in Sitewide automatically converts any links on your page to PDF, Word, Excel, or PowerPoint files to use embedit.in in an overlay on your page instead. You can change which links it edits with a simple JavaScript call, which you should include in another script tag below the one that you've already pasted in for embedit.in Sitewide:
EmbedItIn.extensions = /.*\.(pdf|doc|docx|xls|xlsx|ppt|pptx)$/;
</script>
EmbedItIn.extensions is a regular expression that will be matched against the href attribute of each of your links. You can set it to anything you like.


