日期:2014-05-16  浏览次数:20397 次

javascript里对象的永久参数问题
javascript里
<object   classid= "clsid:...... "   id= " ">
<param   name= "filename "   value= " ">
</object>

比如这个对象是一个文件解码器,需要filename的永久参数才能构造出来,而且不能为空,不过我想用打开文件对话框获取这个文件名,然后赋值给filename这个永久参数,如何办到?请大家帮想想办法


------解决方案--------------------
看一下我刚写的代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> TEST </title>
</head>

<body>
<script type= "text/javascript ">
// <![CDATA[
function openFile(oFile)
{
var sFileName = oFile.value;
var oFlash = ' <object id= "mp3play " width= "520 " height= "390 " align= "middle " codebase= "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0 " classid= "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 "> '
+ ' <param value= "sameDomain " name= "allowScriptAccess "/> '
+ ' <param value= " '+sFileName+ ' " name= "movie "/> '
+ ' <param value= "opaque " name= "WMode "/> '
+ ' <param value= "high " name= "quality "/> '
+ ' <param value= "true " name= "allowFullScreen "/> '
+ ' <embed id= "mp3play " width= "520 " height= "390 " align= "middle " pluginspage= "http://www.macromedia.com/go/getflashplayer " type= "application/x-shockwave-flash " flashvars= "url=%2Fdownload%2F%3Fres_id%3D12937%26res_type%3Dvideo&autoplay=true&xhplay=false&ad_url=http%3A%2F%2Fftv.ifensi.com%2Fad%2Fplayer_ad.swf&ad_time=10&pic= " allowfullscreen= "true " allowscriptaccess= "sameDomain " quality= "high " wmode= "opaque " src= " '+sFileName+ ' "/> '
+ ' </object> ';

document.getElementById( 'player ').innerHTML = oFlash;
}

//]]>
</script>
<div id= "player "> </div>
<input type= "file " onchange= "openFile(this); ">
</body>
</html>