简体   繁体   中英

loading swf on chrome with jquery

In chrome the swf would not load until unless there is a click made on the div,what am i doing wrong

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

The preferred way of loading swfs with JavaScript would be to use swfobject , rather than just a plain string and jQuery. There are just way too many issues that arise when doing it the string-way.

An example:

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

Of course you can use jQuery to render the div and then run the embedSWF-function, all in your JavaScript, if you prefer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM