Home > Web Front-end > JS Tutorial > Collection of solutions to the incompatibility between ie and firefox_javascript skills

Collection of solutions to the incompatibility between ie and firefox_javascript skills

WBOY
Release: 2016-05-16 18:53:39
Original
1021 people have browsed it
1. Firefox and IE event processing
In IE, the event object is saved and maintained as a global variable. All browser events, whether triggered by the user
or other events, will update the window.event object. So in the code, you can easily get the event object by simply calling window.event
, and then use event.srcElement to get the element that triggered the event for further processing
In ff, the event object is not a global object, generally In this case, if it happens on-site and is used on-site, ff will automatically pass the event object
to the corresponding event processing function. In the code, the first parameter of the function is the event object under ff.


2. Firefox and IE are not compatible with hand pointer cursor

Hand pointer has cursor:hand and cursor: There are two ways to write pointer, among which cursor:hand is not supported in ff and an error is returned! <script> <BR>function foo4(){ <BR>var evt=getEvent(); <BR>var element=evt.srcElement || evt.target ; <BR>alert(element.id) <BR>} <BR>function getEvent() <BR>{ //同时兼容ie和ff的写法 <BR>if(document.all) return window.event; <BR>func=getEvent.caller; <BR>while(func!=null){ <BR>var arg0=func.arguments[0]; <BR>if(arg0){ <BR>if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){ <BR>return arg0; <BR>} <BR>} <BR>func=func.caller; <BR>} <BR>return null; <BR>} <BR></script> Just use cursor:pointer, both ff and ie support it!
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