I recently worked on a project and encountered the problem of incompatibility between FireFox and IE scripts. For this purpose, I collected some compatible scripts from the Internet. I also explored a bit myself. I originally wrote them in another blog of my own. I have copied them here for future reference. For reference, the original text
1. window.event compatible script
2. Shield the Form submission event
3. Get the event source
4. Add event compatible writing
5. Firefox registration innerText writing
6. Length
7. Under the parent control Sub-control
8. ;
while(func!=null){
var arg0=func.arguments[0];if(arg0){
if((arg0.constructor==Event arg0.constructor ==MouseEvent ) (typeof(arg0)=="object" %26amp;%26amp; arg0.preventDefault %26amp;%26amp; arg0.stopPropagation)){
return arg0;
}
}
func=func.caller;
}
return null;
}
Firefox needs to use getEvent() to get it every time before using the event, otherwise it will be empty
2. Block the Form submission event
event.returnValue=false;// for IE
if (oElement.attachEvent){
oElement.attachEvent(sEvent,func);}
else{sEvent=sEvent.substring(2,sEvent.length);
oElement.addEventListener(sEvent , func, false);}
}
Usage addEvent(window,"onload",Start);
5.Firefox registration innerText writing method
//Register firefox innerText
HTMLElement.prototype.__defineGetter__("innerText",
var anyString = "";
var childS = this.childNodes;for(var i=0; i if(childS[i].nodeType==1)
anyString += childS[i]. tagName=="BR" ? 'n' : childS[i].innerText;else if(childS[i].nodeType==3)
anyString += childS[i].nodeValue;
}
return anyString;
}
);
HTMLElement.prototype.__defineSetter__("innerText",
function(sText){
this.textContent=sText;
}
);
6. Length FireFox length must be added with "px", IE does not matter
7. The child controls under the parent control are "children" in IE and "childNodes" in FireFox
8. Send(" ") should be used, otherwise a 411 error will occur