[英]Having issues running javascript on Visualstudio(MacOS) writing for webdevelopment?
I'm learning to write javascript and here is the code:我正在学习编写 javascript,这是代码:
<!DOCTYPE html Public "-//W3C//DTD XHTML 1.0 Transitional //EN"
"http://www.w3.org/TR/xhtmll/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Chapter 7: Example 1</title>
<script type="text/javascript">
function window_onload()
{
var numberForms = document.forms.length;
var formindex;
for (formIndex = 0; formIndex < numberForms; formIndex++}
{
alert(document.forms(formIndex).name);
}
]
</script>
</head>
<body onload="window_onload()">
<form action="" name="form1">
<p>
This is inside form1.
</p>
</form>
<form action="" name="form2">
<p>
This is inside form2
</p>
</form>
<form action="" name="form3">
<p>
This is inside form3
</p>
</form>
</body>
</html>
I have saved the file as a.html, .js and a.htm and had no luck in getting it up and running when opening the browser and I'm looking for a reason why this has happened.我已将文件保存为 a.html、.js 和 a.htm,但在打开浏览器时无法启动并运行它,我正在寻找发生这种情况的原因。
You've got several syntax errors.你有几个语法错误。 In the
window_onload
function you have a }
instead of a closing )
.在
window_onload
function 你有一个}
而不是关闭)
。
There's also a random ]
at the very end of the function and your function is missing a closing )
在 function 的最后还有一个随机的
]
,而您的 function 缺少关闭)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.