Chrome can't call alert or confirm at onload?

67 5

I've a page that's written like this.

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script>
function test()
{
 alert("testing."); 
}
</script>
</head>
<body onLoad="test();">
</body>
</html>

It's found that there's a JavaScript error when you call the alert window.

Uncaught: cannot read property 'hasport 'of undefined

Because this error leads to the function that I later can't parse.
I'd like to ask, this is chrome is error or my function error. Is there any way to solve it?
My chrome is 16 beta and 17 dev edition.

3 Answers

101 5

Can run
Code is as follows:

<!DOCTYPE html>
<html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 <title>New Web Project</title>
 <script type="text/javascript">
 function test(){
 alert("ok?!");
 }
 </script>
 </head>
 <body onload="test();">
 </body>
</html>
...