While investigating a reported problem with my site loading slowly, I came across an issue where I noticed (via firebug) that my flash file was loading twice.
After a bit of investigation I tracked it down to a firefox bug combined with the usage of SWFObject 2.0.
Now, I noticed on the thread that someone mentioned that you can workaround the problem by:
FYI, if you're a webpage developer then an easy workaround to get your page working with FF3 is to delay accessing any plugins until after your page has fully loaded. An easy way to do this is to schedule your plugin scripting code to run after all pending browser events using window.setTimeout with a timeout of zero.
Honestly, I have no clue what they're saying and am hoping someone can give me a code example that will work.
Do you know of a way to make this work and what the code would look like? Any help would be immensely appreciated!
<script>
function loadswf()
{
swfobject.registerObject("myobj", "9.0.0");
}
function init()
{
window.setTimeout("loadswf()", 0);
}
</script>
<body onload="init()">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="778" height="198" id="myobj">
<param name="movie" value="style.swf">
<param NAME=FlashVars VALUE="url={{stylelist}}">
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="style.swf" width="778" height="198">
<param name="flashvars" value="url={{stylelist}}">
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
Make sure you're setting the Cache and Expires headers in the response. I had a similar issue with a pdf in an object tag, calling the server twice. Setting the Expires header to be 5 seconds after the current time prevented the second call. HTH
This can also be caused by improperly configured CDNs, where they might be not sending the full content or throwing a 206 or other http error.
来源:https://stackoverflow.com/questions/499949/flash-loads-twice-workaround