__flash__removeCallback problem on IE6

Every time the page unloads

If there’s a flash movie into your page using the AMF protocol to speak with the other part of the site, there may be a bug under Internet Explorer version 6 … again. The AMF protocol stands for Action Message Format is simply JavaScript – Actionscript way to get connected. And it simply registers the callbacks from both sides. So there’s simply a object/embed pair in the HTML and a Flash movie using AMF, and IE6. Everything’s OK until leaving the page. On unload the window object the generated JavaScript code breaks and throws an error. Usually it’s something like that:

function __flash__removeCallback(instance, name) {
    ... here instance is given null under IE6

What if embed with some js library (SWFObject)

Reading some forum posts it may be working if I was using a js/flash library such as SWFObject, but I don’t want such, because of one another JavaScript file loading and blocking the content. I just wanted the object/embed to be in my page.

Easy to find a solution – difficult to set it up

Beside the well known fact that this instance is null and there’s an error, I couldn’t make

if (instance == null) escape this case ...

because it’s a Flash Player generated source, which is untouchable.

The clear way to the working site

Well on unload of the window object you must remove all the object/embed that’s giving the problem simply by adding that chunk of code:

1. if (document.getElementById(id_of_the_flash_container) != null) {
2.    $(window).unload(function() {
3.         document.getElementById(id_of_the_flash_container).removeChild(document.getElementById(id_of_the_object_tag));
4.    });
5. }

just replace both id_of_the_flash_container, which is some kind of a DIV tag, or other DOM element, and id_of_the_object_tag.

4 thoughts on “__flash__removeCallback problem on IE6

  1. We are using a Gwt project containing a flash file,
    This is in an iframe.
    When a window is closed, the event is tracked and the code works fine,

    however, there is a situation when we call an element’s “clear()” method.
    This throws the famous line 52 error.

    Is there any logic that lets me know that a flash file has completely loaded so that i can overide the
    “__flash__removeCallback” method instead of waiting for window.onunload ??

  2. Thanks! You really helped me to fix this issue on my site!
    For those who use html5 and use object as a fallback for non-html5 browsers, you can just call the object directly by using this

    $(window).unload(function() {

    I’m using jQuery obviously.


Leave a Reply

Your email address will not be published. Required fields are marked *