思路:
A.先隐藏embed标签
B.清除embed元素
C.为embed重新赋值,加入Html页面中
1.html代码
<object id="forfun" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100%"
height="100%" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0">
<param name="movie" value="@firstShop.ID">
<param name="quality" value="high">
<param name="bgcolor" value="#F0F0F0">
<param name="menu" value="false">
<param name="wmode" value="opaque">
<!--Window|Opaque|Transparent-->
<param name="FlashVars" value="">
<!--控制全屏-->
<param name="allowFullScreen" value="true" />
<param name="allowScriptAccess" value="sameDomain">
<embed id="forfunex" src="@firstShop.Shop.FirstSwfUrl"
width="1000"
height="400"
align="middle"
<!--控制全屏---->
allowfullscreen="true"
quality="high"
bgcolor="#f0fff8"
menu="false"
play="true"
loop="false"
FlashVars=""
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer"> </embed>
</object>
2.JS代码
<script type="text/javascript">
$(function () {
var imgs = $(".img");
$.each(imgs, function () {
$(this).click(function () {
var swfPath = $(this).attr("swfPath");
var embed = '<embed id="forfunex" src="' + swfPath + '" width="1000" height="300" align="middle" quality="high" allowfullscreen="true" bgcolor="#f0fff8" menu="false" play="true" loop="false" FlashVars="" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer"> </embed>';
$("forfunex").attr("display", "none");
var object = document.getElementById("forfun");
object.getElementsByTagName("embed")[0].style.display = "none";
object.innerHTML = "";
object.innerHTML = embed;
});
});
});
</script>