This is another way of solving the same problem I raised as createElement('SCRIPT').... in essence, can you use DOM to change a script, or add a script? Consider the following
<html>
<body>
<script language="javascript" id="jTest">
alert("hi"
</script>
<a href="javascript:ChangeScript()">Click Here to change your javascript</a>
<script language="javascript">
function ChangeScript(){
alert(jTest.innerHTML);
var NewScript = document.createTextNode("alert('how are you')"
;
jTest.appendChild(NewScript) ;
//...I've even tried....
//jTest.innerHTML="alert('how are you')"
//...but that doesn't work either....
alert(jTest.innerHTML);
}
</script>
</body>
</html>
Any ideas why it doesn't work? Or how I can use DOM to add a script?
Thanks,
Peter
<html>
<body>
<script language="javascript" id="jTest">
alert("hi"
</script>
<a href="javascript:ChangeScript()">Click Here to change your javascript</a>
<script language="javascript">
function ChangeScript(){
alert(jTest.innerHTML);
var NewScript = document.createTextNode("alert('how are you')"
jTest.appendChild(NewScript) ;
//...I've even tried....
//jTest.innerHTML="alert('how are you')"
//...but that doesn't work either....
alert(jTest.innerHTML);
}
</script>
</body>
</html>
Any ideas why it doesn't work? Or how I can use DOM to add a script?
Thanks,
Peter