chapter31

development in a land far far away…

at the moment

History is not what happened. History is what was written down.

I experienced some strange behaviour today when building a site which was using jQuery and SWFObject. Our Flash files were loading ok and 99% of the javascript (using jQuery) was working fine.

The problem was found only in IE (sound familiar?) with the following code:

When the ’submitButton’ was clicked, this function was not firing in IE. After some googling I found that there is a slight conflict with jQuery and SWFObject. I tested this and found the problem in jQuery 1.1.x and 1.2.1.

I found the fix on the SWFObject forums which is basically using jQuery to load the .swf:

All good in all browsers :)


Related Pages

7 Responses to “jQuery and SWFObject conflict”

  1. if you’re using already jquery, then download the media plugin to write the flash for you.

    http://malsup.com/jquery/media/

    tony petruzzi

  2. Hi Tony,

    The media plugin looks like it adds <object> and <embed> tags which are bad bad bad for many reasons, particularly the IE ‘click here to activate’ issue which happened when Microsoft lost the EOLAS court case a year ago.

    UFO quickly became the standard for embedding Flash, then SWFObject. The authors for both those methods are now working together on a new way to embed Flash etc which I believe doesn’t rely on javascript.

    Anyway, check out SWFObject for more info here: http://blog.deconcept.com/swfobject/

    Michael Sharman

  3. Michael,

    Any JS plugin that manages media adds object/embed tags to the DOM. That exactly what happens when you execute this line in your code:

    so.write(”flashcontent”);

    The jQuery Media Plugin just makes working with media simpler and handles many, many media types beside Flash. It even uses SWFObject if that script is loaded.

    Cheers!

    malsup

  4. @Malsup - Ohhh nice! I just read (a little further than before) up on the media plugin. Man it is nice.

    Thanks for the comment and the info, much appreciated :)

    Michael Sharman

  5. ahhhhh. thanks for posting this. i was … losing it.

    jordan

  6. Thank you so much !

    I was searching a patch that make jquery and swfobject working together and yours is fantastic !

    (sorry for my english, i’m french geek girl)…

    Aurore

  7. @Jordan/@Aurore - Glad it helped :)

    Michael Sharman

Leave a Reply