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.
但我无法让警报生效。我将得到未捕获的ReferenceError: move没有定义。
4 个解决方案
#1
4
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!
原来脚本标记上的语言属性不允许我指定文本/javascript,只允许指定javascript。type属性允许“text/javascript”。就这样,我花了几个小时在javascript代码中寻找bug……参数!
So, basically I changed the line that said
基本上我改变了这条线
<script language="text/javascript">
to
来
<script type="text/javascript">
and it all worked.
这一切奏效了。
#2
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>
#3
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>
#4
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.
如果您正在使用jquery,则xx-x代表您正在使用的版本。
#1
4
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!
原来脚本标记上的语言属性不允许我指定文本/javascript,只允许指定javascript。type属性允许“text/javascript”。就这样,我花了几个小时在javascript代码中寻找bug……参数!
So, basically I changed the line that said
基本上我改变了这条线
<script language="text/javascript">
to
来
<script type="text/javascript">
and it all worked.
这一切奏效了。
#2
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>
#3
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>
#4
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.
如果您正在使用jquery,则xx-x代表您正在使用的版本。