• 用JS改变embed标签的src属性


    思路:

    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>

  • 相关阅读:
    查看文件方法、vim末行操作
    目录结构、文件管理命令
    计算机快捷键、常用命令、别名、
    Redis 使用与优化
    Redis-Sentinel
    Redis主从复制
    Redis持久化
    API的使用
    Redis安装和配置
    集群搭建(脑裂)
  • 原文地址:https://www.cnblogs.com/CeleryCabbage/p/4571937.html
Copyright © 2020-2023  润新知