【坑】Firefox不支持window.event的解决办法
2014-09-12 21:25
387 查看
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <script type="text/javascript"> function Demo(evt) { var temp = window.event ? evt.keyCode : evt.which; alert(temp); } </script> </head> <body> <input type="text" onKeyPress="Demo(event);"> </body> </html>
由于Firefox不支持window.event(这么好的浏览器你居然不支持。。。伤心了)
所以在获取event的时候要判断是否有这个对象先,我这里用的是
var temp = window.event ? evt.keyCode : evt.which;
。。。。(问CSDN的官人,怎么去掉这个代码的灰色背景)
这个evt.which和event有点相似(仅限于判断输入了那个键)
与之类似的还有Firefox的event.preventDefault()可以在IE下使用window.event.returnValue = false;来代替
相关文章推荐
- Firefox不支持removeNode及window.event解决办法
- 有关firefox不响应window.event的解决办法
- 有关firefox不响应window.event的解决办法
- 解决firefox不支持window.event.returnValue = false
- FF 中 window.event 的解决办法总结
- FireFox不支持disable-output-escaping解决办法
- xcode 4.3 不再支持 Window-Based Application 的解决办法
- xcode 4.2 不再支持 Window-Based Application 的解决办法
- Firefox不支持event解决方法
- xcode 4.2 不再支持 Window-Based Application 的解决办法(转载)
- Firefox不支持event解决方法
- 关于ie和firefox下event的兼容解决办法
- 解决Firefox浏览器不支持text-overflow:ellipsis;的办法
- xcode 4.2 不再支持 Window-Based Application 的解决办法(转载)
- 解决window.showModalDialog在Firefox无法支持
- 让firefox支持window.event
- Selenium不支持firefox3的解决办法
- Firefox不支持document.frames["tmpFrame"].location解决办法
- Firefox、Opera 不支持 background-position-x, background-position-y 的解决办法
- 解决Firefox不支持event.keyCode 的方法