83
rated 0 times
[
86]
[
3]
/ answers: 1 / hits: 44705
/ 9 Years ago, tue, july 14, 2015, 12:00:00
I have a body onload calling a function in javascript. I Have tried many things, but the console just prints to the error log: uncaught reference error: start is not defined. I think it might be a malfunction, please notify me if it works for you. My code is as follows:
<!DOCTYPE html>
<html>
<head>
<title>Monster Invasion</title>
<script type=javascript>
var hur;
var monsters = 10;
var objective = false;
var health = 100;
var damage = 30;
var sheild = false;
var ea = 1;
function start() {
setTimeout(hurt,4000)
}
function hurt() {
var newhelth = health - damage;
health = newhelth;
document.getElementById(healtw).innerHTML = health;
start();
}
function kill() {
if(monsters > 0) {
monsters--;
document.getElementById(monster1).src=dead.jpg
setTimeout(next,2000)
}else {
objective = true;
document.location=endoflevel.html;
}
}
function next() {
document.getElementById(monster1).src=monster.jpg
}
}
</script>
</head>
<body onload=start()>
<p id=healtw></p>
<embed src=guide_first_level.mp3 type=audio/mp3 hidden=true autostart=true>
<a id=st onclick=kill()><img id=monster1 src=monster.jpg></a>
<p id=ada></p>
<a href=sheild.html>Activate sheild</a>
</body>
</html>
More From » html