[SWFObject] Race Condition with Javscript and SWFObject

Chris Johnson cjohnson at intermix.com
Tue Jul 11 17:10:28 PDT 2006


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\");fla
shObject.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

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.deconcept.com/pipermail/swfobject-deconcept.com/attachments/20060711/ec42d339/attachment-0004.htm>


More information about the Swfobject mailing list