javascript在html中的引用问题
<scripttype="text/javascript">varstr="{dede:sqlsql="SELECTaid,typeid,videolistFROM`de...
<script type="text/javascript">
var str="{dede:sql sql="SELECT aid,typeid,videolist FROM `dede_addonvideo` where typeid=17 ORDER BY `aid` DESC LIMIT 0 , 1"}
[field:videolist /]
{/dede:sql}";
var reg=/{([a-z])*}/gi;
var reg1="第1集";
var str1=str.replace(reg,"");
var str1=str1.replace(reg1,"");
document.write(str1);
</script>
<embed src="/plus/flvplayer.swf?file=/uploads/media/110301/1-110301201I5.flv " type="application/x-shockwave-flash" width="250" height="165"></embed>
请教个问题,我想把/uploads/media/110301/1-110301201I5.flv 替换成变量str1的值,怎么办?
代码改成了这样还是不行。
<script type="text/javascript">
var str="{dede:sql sql="SELECT aid,typeid,videolist FROM `dede_addonvideo` where typeid=17 ORDER BY `aid` DESC LIMIT 0 , 1"}
[field:videolist /]
{/dede:sql}";
var reg=/{([a-z])*}/gi;
var reg1="第1集";
var str1=str.replace(reg,"");
var str1=str1.replace(reg1,"");
document.write(str1);
var embedobj = document.getElementsByTagId("flashplayer");
</script>
<embed id="flashplayer" embedobj.src = "/plus/flvplayer.swf?file="+str1 type="application/x-shockwave-flash" width="250" height="165"></embed> 展开
var str="{dede:sql sql="SELECT aid,typeid,videolist FROM `dede_addonvideo` where typeid=17 ORDER BY `aid` DESC LIMIT 0 , 1"}
[field:videolist /]
{/dede:sql}";
var reg=/{([a-z])*}/gi;
var reg1="第1集";
var str1=str.replace(reg,"");
var str1=str1.replace(reg1,"");
document.write(str1);
</script>
<embed src="/plus/flvplayer.swf?file=/uploads/media/110301/1-110301201I5.flv " type="application/x-shockwave-flash" width="250" height="165"></embed>
请教个问题,我想把/uploads/media/110301/1-110301201I5.flv 替换成变量str1的值,怎么办?
代码改成了这样还是不行。
<script type="text/javascript">
var str="{dede:sql sql="SELECT aid,typeid,videolist FROM `dede_addonvideo` where typeid=17 ORDER BY `aid` DESC LIMIT 0 , 1"}
[field:videolist /]
{/dede:sql}";
var reg=/{([a-z])*}/gi;
var reg1="第1集";
var str1=str.replace(reg,"");
var str1=str1.replace(reg1,"");
document.write(str1);
var embedobj = document.getElementsByTagId("flashplayer");
</script>
<embed id="flashplayer" embedobj.src = "/plus/flvplayer.swf?file="+str1 type="application/x-shockwave-flash" width="250" height="165"></embed> 展开
2个回答
展开全部
给embed设置一个ID,代码如下:
<embed id="flashplayer" src="/plus/flvplayer.swf?file=/uploads/media/110301/1-110301201I5.flv " type="application/x-shockwave-flash" width="250" height="165"></embed>
通过js获取embed这个标签,代码如下:
var embedobj = document.getElementsById( 'flashplayer');
修改获取对象有src属性即可,代码如下:
embedobj.src = "/plus/flvplayer.swf?file="+str1
document.write(str1);
这个即可替换成str1了,希望能解决你的问题.
你要希望这么改的话,直接在js里面输出html算了,代码如下:
document.write("<embed id='flashplayer' src='/plus/flvplayer.swf?file="+str1+"' type='application/x-shockwave-flash' width='250' height='165'></embed>");
<embed id="flashplayer" src="/plus/flvplayer.swf?file=/uploads/media/110301/1-110301201I5.flv " type="application/x-shockwave-flash" width="250" height="165"></embed>
通过js获取embed这个标签,代码如下:
var embedobj = document.getElementsById( 'flashplayer');
修改获取对象有src属性即可,代码如下:
embedobj.src = "/plus/flvplayer.swf?file="+str1
document.write(str1);
这个即可替换成str1了,希望能解决你的问题.
你要希望这么改的话,直接在js里面输出html算了,代码如下:
document.write("<embed id='flashplayer' src='/plus/flvplayer.swf?file="+str1+"' type='application/x-shockwave-flash' width='250' height='165'></embed>");
展开全部
<script type="text/javascript">
var str="{dede:sql sql="SELECT aid,typeid,videolist FROM `dede_addonvideo` where typeid=17 ORDER BY `aid` DESC LIMIT 0 , 1"}
[field:videolist /]
{/dede:sql}";
var reg=/{([a-z])*}/gi;
var reg1="第1集";
var str1=str.replace(reg,"");
var str1=str1.replace(reg1,"");
document.write(str1);
document.write("<embed id='flashplayer' src='/plus/flvplayer.swf?file="+str1+"' type='application/x-shockwave-flash' width='250' height='165'></embed>");
</script>
var str="{dede:sql sql="SELECT aid,typeid,videolist FROM `dede_addonvideo` where typeid=17 ORDER BY `aid` DESC LIMIT 0 , 1"}
[field:videolist /]
{/dede:sql}";
var reg=/{([a-z])*}/gi;
var reg1="第1集";
var str1=str.replace(reg,"");
var str1=str1.replace(reg1,"");
document.write(str1);
document.write("<embed id='flashplayer' src='/plus/flvplayer.swf?file="+str1+"' type='application/x-shockwave-flash' width='250' height='165'></embed>");
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询