Hi,
I added a JS file to my HTML file programatically.
It appended just fine, but it wont execute the function inside the JS file. Can any see what I'm doing wrong? Thanks.
-----------------------------------
<html>
<head>
<script type="text/javascript">
function FindTotal(first,next,last)
{
var total = first + next + last;
document.write ("Your total is " + total + " . ");
}
</script>
</head>
<body>
<script type="text/javascript">
FindTotal(2,3,4);
document.write("T1");
var ns = document.createElement("script");
ns.type = 'text/javascript';
ns.src = './js8.js';
document.getElementsByTagName('head')[0].appendChild(ns);
document.write("T2");
var i;
var ip = document.getElementsByTagName("script");
for (i = 0; i < ip.length; i++)
{
var type = ip.src;
document.write(type);
}
document.write(j8());
document.write("END");
</SCRIPT>
</body>
</html>
--------------------
js8.js is:
function j8()
{ alert('88888888888888'); }
--- eom ------------
I added a JS file to my HTML file programatically.
It appended just fine, but it wont execute the function inside the JS file. Can any see what I'm doing wrong? Thanks.
-----------------------------------
<html>
<head>
<script type="text/javascript">
function FindTotal(first,next,last)
{
var total = first + next + last;
document.write ("Your total is " + total + " . ");
}
</script>
</head>
<body>
<script type="text/javascript">
FindTotal(2,3,4);
document.write("T1");
var ns = document.createElement("script");
ns.type = 'text/javascript';
ns.src = './js8.js';
document.getElementsByTagName('head')[0].appendChild(ns);
document.write("T2");
var i;
var ip = document.getElementsByTagName("script");
for (i = 0; i < ip.length; i++)
{
var type = ip.src;
document.write(type);
}
document.write(j8());
document.write("END");
</SCRIPT>
</body>
</html>
--------------------
js8.js is:
function j8()
{ alert('88888888888888'); }
--- eom ------------