码迷,mamicode.com
首页 > Web开发 > 详细

用JS改变embed标签的src属性

时间:2015-06-12 17:07:27      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:

思路:

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>

用JS改变embed标签的src属性

标签:

原文地址:http://www.cnblogs.com/weishuanbao/p/4571937.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!