Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught ReferenceError: (function) is not defined

Tags:

javascript

I just think this is useful for people having this problem:

I had this code:

<html>
<head>
    <link rel="stylesheet" href="example.css" type="text/css"/>
    <title>CSS TESTS</title>
    <script language="text/javascript">
        var move = 0;
    </script>
</head>
<body>
    <input type="text" id="shape" onchange="alert(move);"/>
</body>
</html>

But I couldn't get the alert to work. I would get the Uncaught ReferenceError: move is not defined.

like image 757
fiacobelli Avatar asked Jul 17 '12 05:07

fiacobelli


2 Answers

It turns out that the language attribute on the script tag did not allow me to specify text/javascript but only javascript. The type attribute allows "text/javascript". That was all and I spent hours trying to find the bug in the javascript code... arg!

So, basically I changed the line that said

<script language="text/javascript">

to

<script type="text/javascript">

and it all worked.

like image 57
fiacobelli Avatar answered Nov 15 '22 02:11

fiacobelli


Change <script language="text/javascript"> TO <script type="text/javascript">

Working Code --

<html>
<head>
    <link rel="stylesheet" href="example.css" type="text/css"/>
    <title>CSS TESTS</title>
    <script type="text/javascript">
        var move = 0;
    </script>
</head>
<body>
    <input type="text" id="shape" onchange="alert(move);"/>
</body>
</html>
like image 23
swapnesh Avatar answered Nov 15 '22 02:11

swapnesh