Also Firefox findet die Funktion startGame nicht.
Die Fehler-Konsole gibt "startGame is not a function" aus.
JavaScript
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" xml:lang="de">
<head>
<title>Reactio</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<style type="text/css">
*
{
font-size:12px;
}
#blackbg
{
width:500px;
height:200px;
background-color:black;
}
</style>
<script type="text/javascript">
/* <![CDATA[ */
var point_on_screen = false;
var start = false;
document.onkeydown = detectKey;
function startGame(){
timer();
switchPoint();
}
function rand (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function removePoint(){
if(document.getElementById("point") != null){
document.getElementById("blackbg").removeChild(document.getElementById("point"));
}
}
function switchPoint(){
removePoint();
point = new Image();
point.src = "point.gif";
point.id = "point";
margin_left = rand(0,470) + "px";
margin_top = rand(0,170) + "px";
point.style.marginTop = margin_top;
point.style.marginLeft = margin_left;
blackbg = document.getElementById("blackbg");
blackbg.appendChild(point);
pointOnScreen = true;
}
function detectKey (events){
if(!events){
events = window.event;
}
if(events.which){
key = events.which;
if(key == 32){
handleKeyPress();
}
}
else if(events.keyCode){
key = events.keyCode;
if(key == 32){
handleKeyPress();
}
}
}
function timer(stop){
if(stop == true){
clearIntervall();
return milli;
}
milli = 0;
window.setInterval("milli++", 10);
return milli;
}
function handleKeyPress(){
if(point_on_screen && start){
Timer(true);
}
}
/* ]]> */
</script>
</head>
<body>
<div id="info">
<form action="" method="post" onsubmit="">
<p>
<input type="checkbox" id="space" value="0" /><label for="space">Leertaste</label>
</p>
<p>
<input onclick="startGame()" type="button" id="startGame" value="Spiel starten!" />
</p>
</form>
<span id="timer">
</span>
</div>
<div id="blackbg">
</div>
</body>
</html>
Alles anzeigen