我有这段代码:
<script type="text/javascript">
function js() {
var getJs = document.getElementById("jogo");
if (JS == true) { //if button JS is pressed - it is correct?
< script type = "text/javascript"
src = "file1.js" >
} else < script type = "text/javascript"
src = "file2.js" >
</script>
}
</script>
它不起作用。我有两个按钮,如果按下第一个按钮,应该加载file1.js
。如果按下第二个按钮,则应加载file2.js
。
我该怎么做?
eval
作为解决方案。糟糕的指南会建议像eval("document."+id+".value="+numericValue)
这样的代码。那是极其不安全的! - Lekensteyn