Thursday 12 February 2009

SWFObject and LightBox2 - IE Errors

Today a colleague of mine had a problem whereby he was trying to use LightBox 2 in a webpage, but on that page, we received the "Internet explorer cannot open the internet site XXX Operation Aborted" message, and the page doesn't load.

After a lot of debugging, nothing was apparent, and it didn't happen in Firefox.

After reading around a bit, it seems that IE has a few issues with DOM commands, and as such, the SWFObject and Lightbox2 scripts both try to access the DOM at the same time.

So, all I did was move the SWFObject script to the foot of the page, and keep the div that it is written into in its normal place.

Sorted.

2 comments:

  1. That would explain the same error I'm getting, but not sure how to get around it .. is it simply moving the link to the script?

    ReplyDelete
  2. Yes, Simply move the script to the foot of the page. Because the DIV that contained the flash movie was to be rendered at the top of the page in this istance, I left the div there, but put the script that loads the flash object near the end body tag. E.g. at top of the page have a div such as div id="flashcontent", and then near the end body tag, have the script for the flash object, e.g.
    var fo = new FlashObject("../toplogo.swf", "Example", "768", "140", "9", "#FFFFFF");
    fo.addParam("allowScriptAccess", "sameDomain");
    fo.addParam("quality", "high");
    fo.addParam("scale", "noscale");
    fo.addParam("loop", "false");
    fo.addParam("wmode", "transparent");
    fo.write("flashcontent");

    Where the fo.write("flashcontent") then tells the flash object where to be drawn.

    Hope that helps - I would post all the code, but blogger moans about quoting HTML!

    ReplyDelete