动态增加javascript脚本?
怎样实现脚本动态增加?例如我有一段脚本为
<script> function aa() {
alert( "aa ");
}
</script>
我需要按一下按钮后,把上面代码改为
<script> function aa() {
alert( "aa ");
alert( "add new script ");
}
</script>
怎么实现呢?
------解决方案--------------------jacklinchen(陈) 的方法好像与 LZ 要求的方法不符!
LZ 把 DOM 对象与 function 混淆了,认真看看基础知识吧,
LZ 期望的效果如下,L@_@K
点几次 change,就添加几句 alert( "add new script ");
<body>
<script>
function changeAa()
{
if (aa)
{
var funcTemp = aa;
aa = function() {
funcTemp();
alert( "add new script ");
};
}
}
function aa()
{
alert( "aa ");
}
</script>
<input type= "button " name= "b1 " onclick= "changeAa() " value= "change ">
<input type= "button " name= "b1 " onclick= "aa() " value= "call aa ">
</body>