javascript 尝试在javascript中调用函数时出现“预期对象”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15757445/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 02:00:20 来源:igfitidea点击:
Getting "object expected" error when trying to call a function in javascript
提问by user2234760
The window.alert function does not work and the debugger in internet explorer highlights
window.alert 功能不起作用,Internet Explorer 中的调试器突出显示
registerForm()
in the onclick event on line 15 and gives the error "Object Expected".
在第 15 行的 onclick 事件中,并给出错误“预期对象”。
<!DOCTYPE html>
<head>
<title></title>
<meta charset="utf-8" />
<script type="text/javscript">
/* <![CDATA[ */
function registerForm() {
window.alert("Function is working");
}
/* ]]> */
</script>
</head>
<body>
<form action="" method="get" enctype="application/x-www-form-urlencoded">
<p><input type="button" value="Register" onclick="registerForm();" /></p>
</form>
</body>
</html>
</body>
采纳答案by Sudhir Bastakoti
change
改变
<script type="text/javscript">
to
到
<script type="text/javascript"> //you missed "a" in script tag