浏览 2832 次
锁定老帖子 主题:prototype event 的错误
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-04-28
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <script type="text/javascript" src="js/prototype.js"></script> <script language="javascript"> Event.observe('123', 'click', function(event) { //var elt = Event.element(event); alert('elt'); }); </script> <title>测试</title> </head> <body> <p id="123">sdfasdfafasf</p> </body> </html> 然后firefox报了如下的错误: 错误: element has no properties 源文件:file:///E:/doc/test/js/prototype.js 行:2239 大家有遇到这个问题么? 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-04-28
补充下,prototype是1.5.0的
|
|
返回顶楼 | |
发表时间:2007-04-28
页面没有初始化好 你就 执行 js 了 当然会错
一般写 body 的 onload 或者 Event.observe(window, 'load', function(){ Event.observe('123', 'click', function(event) { alert('elt'); }); }) 另外 script 用 type 不要用 language id 不要用数字开头 |
|
返回顶楼 | |