读书人

EMBED标签中的src接收js传来的动态路径

发布时间: 2012-09-21 15:47:26 作者: rapoo

EMBED标签中的src接收js传来的动态路径的问题

HTML code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>无标题页</title>    <script type="text/javascript" src="js/jquery.js"></script><script language="javascript" type="text/javascript"> var src="playFile\201209132241085625.swf"; var html = '<EMBED src="' + src + '" width="800" height="1000" play="true" loop="false" menu="true" quality="high" type="application/x-shockwave-flash" name="myFlash" swLiveConnect="true" ></EMBED>';  $("#div_video").html(html);</script></head><body>    <form id="form1" runat="server">    <div id="div_video">            <EMBED src="playFile\a.swf" width="800" height="1000" play="true" loop="false" menu="true" quality="high" type="application/x-shockwave-flash" name="myFlash" swLiveConnect="true" ></EMBED>   </div>    </form></body></html>


上述代码是想在网页中动态的插入swf文件,要用js变量来更改EMBED标签的src属性的值,这是重写整个EMBED标签,但是并不能达到目的,试了很多修改都不好,哪位高手能帮我看看,感激不尽

[解决办法]
改变方法
HTML code
<body><script>var swf = ["http://flash.1t2t.com/1t2t_wos1_02.swf","http://flash.1t2t.com/1t2t_wos1_03.swf","http://flash.1t2t.com/1t2t_wos1_04.swf"]var isIE = window.navigator.userAgent.indexOf("MSIE")>-1;var i = 1;function changeSwf(){if(i>=swf.length) i=0;if(isIE){document.getElementById("player").src=swf[i];document.getElementById("player").Movie=swf[i];}else{ document.embeds["myFlash"].src=swf[i];}i++;}</script><input type=button value="change" onclick="changeSwf()"/><br/><EMBED id="player" src="http://flash.1t2t.com/1t2t_wos1_01.swf" width="400" height="200" play="true" loop="false" menu="true" quality="high" type="application/x-shockwave-flash" name="myFlash" swLiveConnect="true" ></EMBED> 

读书人网 >asp.net

热点推荐