admin管理员组文章数量:1421000
The window.alert function does not work and the debugger in internet explorer highlights
registerForm()
in the onclick event on line 15 and gives the error "Object Expected".
<!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>
The window.alert function does not work and the debugger in internet explorer highlights
registerForm()
in the onclick event on line 15 and gives the error "Object Expected".
<!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>
Share
Improve this question
asked Apr 2, 2013 at 6:20
user2234760user2234760
1433 gold badges5 silver badges16 bronze badges
3
-
Try with just
alert
, no "window." – elclanrs Commented Apr 2, 2013 at 6:21 -
1
@elclanrs:
alert === window.alert
– Michael Geary Commented Apr 2, 2013 at 6:23 -
I know, but you're never wrong to assume it could be an IE bug xD. Who knows, maybe it changes the context of
window
for some unknown reason. Seems like this is not the case by looking at the answer. – elclanrs Commented Apr 2, 2013 at 6:36
1 Answer
Reset to default 1change
<script type="text/javscript">
to
<script type="text/javascript"> //you missed "a" in script tag
本文标签: Getting quotobject expectedquot error when trying to call a function in javascriptStack Overflow
版权声明:本文标题:Getting "object expected" error when trying to call a function in javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745338355a2654146.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论