[JavaScript]Event Object in FireFox and IE
来源:互联网 发布:mac 安全设置偏好 编辑:程序博客网 时间:2024/06/05 04:14
How to get event object in FireFox and IE?
* static event function which worked both IE and FireFox
<body onmousemove="displaycoordNS(event);">
<script>
function displaycoordNS(oEvent){
window.document.title=oEvent.clientX+" : "+oEvent.clientY;
}
</script>
<form>
<div id="div1" >aaaa</div>
</form>
</body>
* dynamic event function which worked both IE and FireFox
<body">
<script>
function Button1_onclick() {
var oH = document.getElementById("div1");
eval("oH.onclick = div1_onclick");
}
function Button2_onclick() {
var oH = document.getElementById("div1");
eval("oH.onclick = null");
}
function div1_onclick(oEvent) {
if (oEvent == undefined)
{ // IE
oEvent = event;
}
alert("div1_onclick2:" + oEvent.type);
}
</script>
<form>
<div id="div1" >aaaa</div>
<div id="div2" ><input id="Button1" type="button" value="enable" onclick="return Button1_onclick()" /></div>
<div id="div3" ><input id="Button2" type="button" value="disable" onclick="return Button2_onclick()" /></div>
</form>
</body>
IE: var oEvent = window.event; //or event
in FireFox, it is more complex, you can use different method:
* use callee method.
<body onmousemove="displaycoordNS();">
<script>
function displaycoordNS(){
var oEvent = arguments.callee.caller.arguments[0];
window.document.title=oEvent.clientX+" : "+oEvent.clientY;
}
</script>
<form>
<div id="div1" >Firefox event object</div>
</form>
</body>
* use apply method
<body onmousemove="displaycoordNS.apply(this, arguments);">
<script>
function displaycoordNS(){
var oEvent = arguments[0];
window.document.title=oEvent.clientX+" : "+oEvent.clientY;
}
</script>
<form>
<div id="div1" >Firefox event object</div>
</form>
</body>
* static event function which worked both IE and FireFox
<body onmousemove="displaycoordNS(event);">
<script>
function displaycoordNS(oEvent){
window.document.title=oEvent.clientX+" : "+oEvent.clientY;
}
</script>
<form>
<div id="div1" >aaaa</div>
</form>
</body>
* dynamic event function which worked both IE and FireFox
<body">
<script>
function Button1_onclick() {
var oH = document.getElementById("div1");
eval("oH.onclick = div1_onclick");
}
function Button2_onclick() {
var oH = document.getElementById("div1");
eval("oH.onclick = null");
}
function div1_onclick(oEvent) {
if (oEvent == undefined)
{ // IE
oEvent = event;
}
alert("div1_onclick2:" + oEvent.type);
}
</script>
<form>
<div id="div1" >aaaa</div>
<div id="div2" ><input id="Button1" type="button" value="enable" onclick="return Button1_onclick()" /></div>
<div id="div3" ><input id="Button2" type="button" value="disable" onclick="return Button2_onclick()" /></div>
</form>
</body>
IE: var oEvent = window.event; //or event
in FireFox, it is more complex, you can use different method:
* use callee method.
<body onmousemove="displaycoordNS();">
<script>
function displaycoordNS(){
var oEvent = arguments.callee.caller.arguments[0];
window.document.title=oEvent.clientX+" : "+oEvent.clientY;
}
</script>
<form>
<div id="div1" >Firefox event object</div>
</form>
</body>
* use apply method
<body onmousemove="displaycoordNS.apply(this, arguments);">
<script>
function displaycoordNS(){
var oEvent = arguments[0];
window.document.title=oEvent.clientX+" : "+oEvent.clientY;
}
</script>
<form>
<div id="div1" >Firefox event object</div>
</form>
</body>
- [JavaScript]Event Object in FireFox and IE
- JavaScript Var 'Undefined' in Firefox; IE and Opera Work fine
- Professional JS(13.3.1Event Object in DOM/IE/Cross-Browser/UI&Focus&Mouse and Wheel event[half])
- event ie firefox 兼容性问题
- Get the content of an Iframe in Javascript – crossbrowser solution for both IE and Firefox
- Defined XmlHttp Object for both IE and FireFox
- IE和Firefox下event
- IE FireFox 兼容性之 event
- Object-Oriented Event Listening through Partial Application in JavaScript
- ie and mozillar firefox
- ie firefox javascript
- ie firefox javascript
- ie firefox javascript
- IE和Firefox下event乱谈
- 兼容ie和 firefox的event事件
- IE和Firefox下event乱谈
- 兼容IE和Firefox的event对象
- IE和Firefox下event乱谈
- 计算出你和另一个人的关系,准的邪门了!
- 简介使用ASP.NET访问Oracle数据库的方法
- Hibernate
- Svchost.exe服务
- 删除文件夹目录(包括子文件夹)
- [JavaScript]Event Object in FireFox and IE
- 用CMSS指令提高串口群发短信的效率
- ASP.NET编程中的十大技巧
- Winsock 完成端口模型简介
- 出租网管-每月300元!服务范围:北京地区!
- 异步IO、APC、IO完成端口、线程池与高性能服务器之三 IO完成端口
- 用完成端口开发大响应规模的Winsock应用程序
- 好书推荐
- 字符串排序的程序代码 acm试题