Home  >  Article  >  Web Front-end  >  javascript event在FF和IE的兼容传参心得(绝对好用)_javascript技巧

javascript event在FF和IE的兼容传参心得(绝对好用)_javascript技巧

WBOY
WBOYOriginal
2016-05-16 16:42:201320browse

event在IE和FF不兼容,今天传参碰到些问题,参考网上的一些方法,有所心得:

aClassArray[i].onmouseover = function () { //代码直接写在里面是可以的,要传参也可以传,只是不方便复用 };

aClassArray[i].onmouseover =linkMouseover//不传参的情况下是可以用的,但后续不能用 arguments.callee.caller.arguments[0]

aClassArray[i].onmouseover =linkMouseover()//加括号是错误用法

aClassArray[i].onmouseover = function () { linkMouseover(this) };//this能传进去,可以alert出来,但evt.clientX + "px"就出问题了,是空的。。。 arguments.callee.caller.arguments[0]//可以用这个解决

var src = evt.srcElement || evt.target; //后续还可以跟src

===========================================================================

附上练习代码












Statement:
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