user3653451
user3653451

Reputation: 13

Javascript Works in chrome but not Firefox even in safemode

I have written the following JavaScript code it works fine on Google Chrome Version 34.0.1847.137 but not on Firefox 29.0.1. Found the problem on Mac OSX 10.9 but have been able to recreate it on Ubuntu 14.04. I have even ran Firefox in safemode. I am very new to JavaScript and am trying to create at Tic Tac Toe Game. Thanks in advance for any help you provide.

    <!doctype html>

<html lang="en">
<head>
    <style>
        .Square {
            width: 40px;
            height: 40px;
            text-align: center;
            font-size: 18pt;
            font-weight: bold;
            font-family: Verdana;
        }
    </style>


<script>

    function startGame() {
        document.turn = "X";

        setMessage(document.turn + " gets to start.");
    }

    function setMessage(msg) {
        document.getElementById("message").innerText = msg;
    }


</script>
</head>

<body onload="startGame();">
    <h1>Welcome</h1>

    <div id="message">messages will go here</div>

</body>

Upvotes: 0

Views: 122

Answers (1)

RienNeVaPlu͢s
RienNeVaPlu͢s

Reputation: 7632

Propably because of innerText. See this question for further information.

Try using innerHTML / textContent instead:

document.getElementById("message").innerHTML = msg;

Upvotes: 2

Related Questions