7

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.

asked Jul 17, 2012 at 5:38

4 Answers 4

6

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.

answered Jul 17, 2012 at 5:39
Sign up to request clarification or add additional context in comments.

2 Comments

Better you remove it completely: <script>...</script>. That works fine in HTML5 and probably also browsers that don't understand HTML5.
Oh man thanks you so much :) :) :) You save my more hours. I have spent 2 hours in it :(
3

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>
answered Jul 17, 2012 at 5:49

Comments

0

or do this, here "move" casted as string

<html>
<head>
 <link rel="stylesheet" href="example.css" type="text/css"/>
 <title>CSS TESTS</title>
</head>
<body>
 <input type="text" id="shape" onchange="alert('move');"/>
</body>
</html>
answered Jul 17, 2012 at 5:52

Comments

0

Dont forget to include ,

 <script src="jquery-1.xx.x.min.js" type="text/javascript"> </script>

if you are using jquery, xx-x stand for the version you are using.

answered Sep 3, 2013 at 15:35

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.