scripts.innerHTML怎么改变?
<script>
function $2()
{
var sc=document.scripts[1];
sc.innerHTML+= "function $3(){alert(0);} ";
alert(sc.innerHTML);
}
</script>
<script> function $4(){alert(0);}
</script>
<input type= 'button ' id= 'hjx ' value= '点我呀 ' onclick= '$3() '>
<input type= 'button ' id= 'hjx ' value= '点我呀 ' onclick= '$2() '>
为什么改变script.innerHTML会出错呢?查看帮助文档发现该属性是可读写的呀?
------解决方案--------------------晕倒,以前一直是做个文件用动态生成script,然后修改src来做的,刚才查了下资料原来是可以的
<script>
function $2()
{
var sc=document.scripts[1];
sc.text+= "function $3(){alert(0);} ";
alert(sc.innerHTML);
}
</script>
<script> function $4(){alert(0);}
</script>
<input type= 'button ' id= 'hjx ' value= '点我呀 ' onclick= '$3() '>
<input type= 'button ' id= 'hjx ' value= '点我呀 ' onclick= '$2() '>