Home > Web Front-end > JS Tutorial > Compatibility function to replace window.event.srcElement effect_javascript skills

Compatibility function to replace window.event.srcElement effect_javascript skills

WBOY
Release: 2016-05-16 18:38:53
Original
1119 people have browsed it
Copy code The code is as follows:

function getEvent()
{
var i = 0 ;
if(document.all){
return window.event;
}

func = getEvent.caller;
while(func != null)
{
var arg0 = func.arguments[0];
if(arg0)
{
if(arg0.constructor == MouseEvent)
{
return arg0;
}
}
func = func.caller;
}
return null;
}

If you want to make a reference in the function, you must pass the parameter e before you can wait:
Copy code The code is as follows:

function buttonOver(e)
{
e = getEvent( );
var obj = e.srcElement || e.target;
if (obj.runtimeStyle){
obj.runtimeStyle.cssText = "background-color:#FFFFFF";
}
else
obj.style.background = "#FFFFFF";
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template