将JS变量插入html标记

时间:2011-07-11 23:06:16

标签: javascript html

我正在尝试在html标签中插入一个JS变量,我不知道我做错了什么。电影无法加载。这是我的代码:

var moviePath = "images/main.swf";    
<script>document.write('<PARAM name="movie" value="' + moviePath + '">')</script> 

1 个答案:

答案 0 :(得分:6)

您的var似乎不在您的脚本之内..?

尝试:

<script type="text/javascript">
    var moviePath = "images/main.swf";
    document.write('<param name="movie" value="' + moviePath + '">');
</script>