我刚开始学习JAVASCRIPT,想把下面这段定义成一个函数:function flvurl(url).但无论如何也搞不定,恳请高手帮帮忙.
<table border="0" width="200" cellspacing="0" cellpadding="0" >
<tr >
<td width="200">
<div id="player5" style="width:200px; margin:0px; border:solid 5px #50031a;color:#000000;" ><br />
</div>
<div style="width:200px; margin:0px; color:#ffffff;" ><br />
</div>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var s5 = new SWFObject("FlvPlayer201002.swf","playlist","200","189","7");
s5.addParam("allowfullscreen","true");
s5.addVariable("autostart","true");
s5.addVariable("image","flash5.jpg");
s5.addVariable("file","xxxxxxxxxxxxxxx.flv");
s5.addVariable("width","200");
s5.addVariable("height","189");
s5.write("player5");
</script>
</td>
</tr>
</table>
<table border="0" width="200" cellspacing="0" cellpadding="0" >
<tr >
<td width="200">
<div id="player5" style="width:200px; margin:0px; border:solid 5px #50031a;color:#000000;" ><br />
</div>
<div style="width:200px; margin:0px; color:#ffffff;" ><br />
</div>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
var s5 = new SWFObject("FlvPlayer201002.swf","playlist","200","189","7");
s5.addParam("allowfullscreen","true");
s5.addVariable("autostart","true");
s5.addVariable("image","flash5.jpg");
s5.addVariable("file","xxxxxxxxxxxxxxx.flv");
s5.addVariable("width","200");
s5.addVariable("height","189");
s5.write("player5");
</script>
</td>
</tr>
</table>
起碼,我的JavaScript版本还不支持對象定義。
function flvurl(url,w,h,id){
var s5 = new SWFObject(FlvPlayer201002.swf,"playlist",w,h,"7");
s5.addParam("allowfullscreen","true");
s5.addVariable("autostart","true");
s5.addVariable("image","flash5.jpg");
s5.addVariable("file",url);
s5.addVariable("width","200");
s5.addVariable("height","189");
s5.write(id);
}
flvurl("xxxxxxxxxxxxxxx.flv","200","189","player5");
</script> 大体这样吧
function flvurl(url,img,w,h,id){
var s5 = new SWFObject(FlvPlayer201002.swf,"playlist",w,h,"7");
s5.addParam("allowfullscreen","true");
s5.addVariable("autostart","true");
s5.addVariable("image",img);
s5.addVariable("file",url);
s5.addVariable("width",w);
s5.addVariable("height",h);
s5.write(id);
}
flvurl("xxxxxxxxxxxxxxx.flv","flash5.jpg","200","189","player5");
</script>