我试图在 html 标签中插入一个 JS 变量,但我不知道我做错了什么。电影无法加载。这是我的代码:
var moviePath = "images/main.swf";
<script>document.write('<PARAM name="movie" value="' + moviePath + '">')</script>
最佳答案
你的变量似乎在你的脚本之外..?
尝试:
<script type="text/javascript">
var moviePath = "images/main.swf";
document.write('<param name="movie" value="' + moviePath + '">');
</script>
关于javascript - 将 JS 变量插入 html 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6657736/