I simply wanted to have a copy of Mark's classic flashblockplugin. There are better, more flexible detects available now (modernizr beings my favorite).
This is a pure-JavaScript library that detects whether Flash is blocked on the current page due to a Flash blocking extension. The current version can detect
- FlashBlock #1 for Chromium / Google Chrome (Windows/Mac/Linux)
- FlashBlock #2 for Chromium / Google Chrome (Windows/Mac/Linux)
- FlashBlock for Firefox (Windows/Mac/Linux)
- ClickToFlash 1.5.x (Mac/Safari only)
This library does not interfere with, or try to counteract, any Flash blocking extensions. It simply tells you whether a blocker is active on your page. Note: if the user has a Flash blocker but has whitelisted your site, the library will (correctly) say that Flash is not blocked.
Because some Flash blockers are not instantaneous, this library inserts some dummy Flash objects into the page and then waits for up to 5 seconds to see if they get blocked. To use the library, you must give it a callback function. If a Flash blocker is active, your callback function will be called almost immediately. If no Flash blocker is active, your callback function will be called after the 5 second timeout. Your callback function should take a single boolean parameter, which will be true if a Flash blocker is active, or false otherwise.
The library cleans up after itself, so there should be no remnants of its dummy Flash objects in the DOM by the time your callback function is called.
Example usage:
<script src="http://flashblockdetector.googlecode.com/hg/fbd.js"></script>
<script>
FBD.initialize(my_callback_function);
function my_callback_function(flash_is_blocked) {
if (flash_is_blocked) {
/* ... do whatever you like ... */
} else {
/* ... do something else, or nothing ... */
}
}
</script>
For best performance, put this script at the bottom of your page, not at the top.