简体   繁体   中英

Getting “object expected” error when trying to call a function in javascript

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>

change

<script type="text/javscript">

to

<script type="text/javascript"> //you missed "a" in script tag

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM