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