锁定老帖子 主题:关于Event.observe的问题
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-06-08
[event||window.event...] 并非让ff下有window.event对象,而是让ie下方法第一个参数为event对象,而不需要访问window.event。
|
|
返回顶楼 | |
发表时间:2007-06-08
我明白了,他是把event对象和我所有的参数放在一个数组里,返回
concat String和Array都有这个方法 |
|
返回顶楼 | |
发表时间:2007-08-29
campaign 写道 <html> <head> <script src="prototype.js" type="text/javascript"></script> <script language="javascript" type="text/javascript"> Event.observe(window,'load', function(){Event.observe('set1','change', function(){ //在ff下 if(this.vlaue) $('tx1').hide(); else $('tx1').show(); //在ie下this没有指象select if(event.srcElement.value) $('tx1').hide(); else $('tx1').show(); }) }) </script> <title></title> </head> <body> <input id='tx1' name='tx1'/> <select id='set1' > <option >choose</option> <option value='1' >1</option> <option >2</option> <option >3</option> </select> </body> </html> 在ff下this指向select元素,在ie下我用for in 只打出了_extend不知道为什么?prototype不是跨浏览器吗 不使用this还是有可能通用的,直接在事件处理函数中使用Event.element(event)获得事件来源对象 Event.observe('set1','change', function(event){ //在ff下 if(Event.element(event).vlaue) $('tx1').hide(); else $('tx1').show(); }) 注意function()改成了function(event) |
|
返回顶楼 | |