Flash loads twice workaround?

半城伤御伤魂 提交于 2019-12-09 17:17:56

问题


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!


回答1:


<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>             



回答2:


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




回答3:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!