我有一个页面是这样写的
<!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>
在用chrome调用时发现在alert窗口出来的时候有一个javascript错误
Uncaught TypeError: Cannot read property 'hasPort' of undefined
因为这个错误导致我后面的函数无法正常解析。
我想请问一下,这是chrome的错误还是我的函数错误?有没有办法解决?
我的chrome是16 beta和17 dev版的。
解决方案
可以运行
code如下:
<!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>