用jquery在chrome上加载swf

时间:2011-02-02 07:01:54

标签: jquery html jquery-ui google-chrome flash

在chrome中,除非在div上发出点击,否则swf不会加载,我做错了什么

 var html += '<div align="center"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  id="myMovieName">';

  html += ' <PARAM NAME="movie" VALUE="/media/cam.swf" /> <PARAM NAME="quality" VALUE="high" /> <PARAM NAME="bgcolor" VALUE="#FFFFFF" /> <EMBED href="/media/players/camera.swf" src="/media/players/camera.swf" quality=high bgcolor=#FFFFFF NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash"> </EMBED> </OBJECT></div>';

 $("#contents").append(html);

1 个答案:

答案 0 :(得分:1)

使用JavaScript加载swfs的首选方法是使用swfobject,而不仅仅是一个普通的字符串和jQuery。在使用字符串方式时,会出现太多问题。

一个例子:

<!-- Include swfobject -->
<script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>

<!-- Put this somewhere on your page -->
<div id="place_to_put_the_swf">
   The content inside this div will be seen if 
   the user doesn't have flash installed.
   Put an image, error message or whatever here.
</div>

<!-- This script with replace the div above with the following swf.
     The parameters are filename, id of the div, width, height and flash version. -->
<script>
  swfobject.embedSWF("file.swf", "place_to_put_the_swf", 400, 300, "7");
</script>

当然,如果您愿意,可以使用jQuery渲染div,然后在JavaScript中运行embedSWF函数。