function PlaySound(file)
{
var str = '<embed id="read_sound" autostart="true" src=file></embed>';
document.getElementById('read_sound').outerHTML = str;
}
如代码所见,这是个一个播放音乐的函数,而参数就是文件名,可是怎么才能把file赋值给<embed>的src?
上面这代码是错误的,
求教?
------解决方案--------------------
<!DOCTYPE HTML>
<html>
<head>
<meta charset="gbk" />
<title></title>
<style>
div {
border:1px solid red;
}
</style>
</head>
<body>
<div id="test"></div>
<script type="text/javascript">
function PlaySound(file)
{
var str = '<embed id="read_sound" autostart="true" src="'+ file +'"></embed>';
document.getElementById('test').innerHTML = str;
}
PlaySound('test.swf')
</script>
</body>
</html>