[英]javascript wont run on my browser
I am following an on-line tutorial on JavaScript. 我正在关注有关JavaScript的在线教程。 Currently the guy is teaching functions, when I copy what he is doing and have exactly the same text on my editor it does not work on chrome or any other browser.
目前,该人员正在教功能,当我复制他的工作并且在我的编辑器中具有完全相同的文本时,它将无法在chrome或任何其他浏览器上使用。
I did some research and people were saying JavaScript is blocked, however I checked in chrome and its not. 我做了一些研究,有人说JavaScript被阻止,但是我检查了chrome,但没有检查。 I went to settings, content settings and I can see that is says " Allow all sites to run JavaScript (recommended)".
我去了设置,内容设置,我看到的是“允许所有站点运行JavaScript(推荐)”。
I do not get an error, just a blank page. 我没有收到错误,只是空白页。 I am completely new to programming and this is putting me off the tutorial.
我是编程的新手,这使我不熟悉本教程。
<!DOCTYPE html>
<html>
<head
<title>Functions</title>
</head>
<body>
<script type="text/javascript">
var foo = doSomething(2);
var bar = doSomething(3);
function doSomething(paramOne){
paramOne = paramOne + 3;
paramOne = paramOne + 1;
paramOne = ParamOne * 8 ;
return paramOne;
}
alert(foo);
alert(bar);
</script>
</body>
</html>
If you look in Chrome's console ( right-click > Inspect Element , select the Console tab) 如果您在Chrome浏览器的控制台中查看( 右键单击 > 检查元素 ,选择“ 控制台”选项卡)
You'll see: 你会看到的:
Uncaught ReferenceError: ParamOne is not defined
This is because you have a capital P
on ParamOne
in your third line. 这是因为你有一个资本
P
上ParamOne
在第三行。
Because Javascript (and most other programming languages ) are case-sensitive, you'll need to make it lowercase: 因为Javascript(和大多数其他编程语言 )区分大小写,所以您需要将其小写:
paramOne = paramOne + 3;
paramOne = paramOne + 1;
paramOne = paramOne * 8;
// ^ was a capital P
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.