[SWFObject] Race Condition with Javscript and SWFObject

bunnyhero (wayne) bunnyhero at gmail.com
Wed Jul 12 23:40:23 PDT 2006


i have also encountered this issue in IE when writing out script tags
to include other scripts (in my case, not using swfobject.js, but
another external .js file). i haven't done much research on this. i
eventually gave up and hard-coded the <script src=""> into the HTML,
rather than document.write()ing it.

(apologies for the extremely awkward wording!)


On 7/11/06, Chris Johnson <cjohnson at intermix.com> wrote:
>
>
>
>
> Hello there.
>
>
>
> I have a page (say, page.js) called from a script tag as such:
>
> <script src="page.js"></script>
>
>
>
> Within page.js, I have something like the following:
>
> document.write("<html><head><script type=\"text/javascript\"
> src=\"/flashobject.js\"><\/script></head>");
>
> document.write("<body><div id=\"flashContainer\" ></div>");
>
> document.write("<script type=\"text/javascript\">var flashObject=new
> FlashObject(\"test.swf\",\"test\",\"425\",\"600\",\"6\",\"#FFFFFF\");flashObject.write(\"flashContainer\");<\/script></body></html>");
>
>
>
>
>
> This works fine in Firefox, but in IE, 50% of the time, I get a message
> saying "Error: 'FlashObject' is undefined".  If I add a "defer" attribute to
> the script tag, I get the error less frequently.  I am pretty sure this is
> caused by a race condition.  I would like to think that the contents of
> flashobject.js will be loaded first, preserving sequence, but this does not
> appear to be the case…
>
>
>
> Any suggestions or insights are appreciated.
>
> Thanks,
>
> Chris
>
>
> _______________________________________________
> SWFObject mailing list
> SWFObject at lists.deconcept.com
> http://lists.deconcept.com/listinfo.cgi/swfobject-deconcept.com
>
>
>



More information about the Swfobject mailing list