If (! Document. all ){
// Zzcv ff ie compatible script
/* Unresolved issues and handling of the script:
2. in IE, you can use () or [] to obtain the collection class object. In Firefox, you can only use [] to obtain the collection class object.
Solution: use [] to retrieve collection class objects.
3. in IE, you can use the method to obtain general attributes to obtain custom attributes, or you can use getAttribute () to obtain Custom Attributes. In Firefox, you can only use getAttribute () to obtain custom attributes.
Solution: getAttribute () is used to obtain custom attributes.
4. in IE, the ID of the HTML object can be directly used as the variable name of the subordinate object of the document; in Firefox, the ID cannot.
5. In Firefox, variable names with the same HTML Object ID can be used; in IE, variable names cannot be used.
Solution: Use document. getElementById ("idName") replaces document. idName. we recommend that you do not use variable names with the same HTML Object ID to reduce errors. When declaring variables, add var to avoid ambiguity.
6. The input. type attribute in IE is read-only, but the input. type attribute in Firefox is read/write.
8. In IE, you can use showModalDialog and showModelessDialog to open modal and non-modal windows. In Firefox, you cannot
9. The body of Firefox exists before the body tag is fully read by the browser. The body of IE must exist only after the body tag is fully read by the browser.
10.
*/
// Document compatibility
HTMLDocument. prototype. _ defineGetter _ ("all", function (){
Return this. getElementsByName ("*");});
HTMLFormElement. constructor. prototype. item = function (s ){
Return this. elements [s];};
HTMLCollection. prototype. item = function (s ){
Return this [s] ;};
// Event compatibility
Window. constructor. prototype. _ defineGetter _ ("event", function (){
For (var o = arguments. callee. caller, e = null; o! = Null; o = o. caller ){
E = o. arguments [0];
If (e & (e instanceof Event ))
Return e ;}
Return null ;});
Window. constructor. prototype. attachEvent = HTMLDocument. prototype. attachEvent = HTMLElement. prototype. attachEvent = function (e, f ){
This. addEventListener (e. replace (/^ on/I, ""), f, false );};
Window. constructor. prototype. detachEvent = HTMLDocument. prototype. detachEvent = HTMLElement. prototype. detachEvent = function (e, f ){
This. removeEventListener (e. replace (/^ on/I, ""), f, false );};
With (window. Event. constructor. prototype ){
_ DefineGetter _ ("srcElement", function (){
Return this.tar get ;});
_ DefineSetter _ ("returnValue", function (B ){
If (! B) this. preventDefault ();});
_ DefineSetter _ ("cancelBubble", function (B ){
If (B) this. stopPropagation ();});
_ DefineGetter _ ("fromElement", function (){
Var o = (this. type = "mouseover" & this. relatedTarget) | (this. type = "mouseout" &&this.tar get) | null;
If (o)
While (o. nodeType! = 1)
O = o. parentNode;
Return o ;});
_ DefineGetter _ ("toElement", function (){
Var o = (this. type = "mouseover" &this.tar get) | (this. type = "mouseout" & this. relatedTarget) | null;
If (o)
While (o. nodeType! = 1)
O = o. parentNode;
Return o ;});
_ DefineGetter _ ("x", function (){
Return this. pageX ;});
_ DefineGetter _ ("y", function (){
Return this. pageY ;});
_ DefineGetter _ ("offsetX", function (){
Return this. layerX ;});
_ DefineGetter _ ("offsetY", function (){
Return this. layerY ;});
}
// Node operation compatibility
With (window. Node. prototype ){
ReplaceNode = function (o ){
This. parentNode. replaceChild (o, this );}
RemoveNode = function (B ){
If (B)
Return this. parentNode. removeChild (this );
Var range = document. createRange ();
Range. selectNodeContents (this );
Return this. parentNode. replaceChild (range. extractContents (), this );}
SwapNode = function (o ){
Return this. parentNode. replaceChild (o. parentNode. replaceChild (this, o), this );}
Contains = function (o ){
Return o? (O = this )? True: arguments. callee (o. parentNode): false ;}
}
// HTML element compatibility
With (window. HTMLElement. prototype ){
_ DefineGetter _ ("parentElement", function (){
Return (this. parentNode = this. ownerDocument )? Null: this. parentNode ;});
_ DefineGetter _ ("children", function (){
Var c = [];
For (var I = 0, cs = this. childNodes; I <cs. length; I ++ ){
If (cs [I]. nodeType = 1)
C. push (cs [I]);}
Return c ;});
_ DefineGetter _ ("canHaveChildren", function (){
Return! /^ (Area | base | basefont | col | frame | hr | img | br | input | isindex | link | meta | param) $/I. test (this. tagName );});
_ DefineSetter _ ("outerHTML", function (s ){
Var r = this. ownerDocument. createRange ();
R. setStartBefore (this );
Void this. parentNode. replaceChild (r. createContextualFragment (s), this );
Return s ;});
_ DefineGetter _ ("outerHTML", function (){
Var as = this. attributes;
Var str = "<" + this. tagName;
For (var I = 0, al = as. length; I <al; I ++ ){
If (as [I]. specified)
Str + = "" + as [I]. name + "=" "+ as [I]. value + """;}
Return this. canHaveChildren? Str + ">": str + ">" + this. innerHTML + "</" + this. tagName + "> ";});
_ DefineSetter _ ("innerText", function (s ){
Return this. innerHTML = document. createTextNode (s );});
_ DefineGetter _ ("innerText", function (){
Var r = this. ownerDocument. createRange ();
R. selectNodeContents (this );
Return r. toString ();});
_ DefineSetter _ ("outerText", function (s ){
Void this. parentNode. replaceChild (document. createTextNode (s), this );
Return s });
_ DefineGetter _ ("outerText", function (){
Var r = this. ownerDocument. createRange ();
R. selectNodeContents (this );
Return r. toString ();});
InsertAdjacentElement = function (s, o ){
Return (s = "beforeBegin" & this. parentNode. insertBefore (o, this) | (s = "afterBegin" & this. insertBefore (o, this. firstChild) | (s = "beforeEnd" & this. appendChild (o) | (s = "afterEnd" & (this. nextSibling) & this. parentNode. insertBefore (o, this. nextSibling) | this. parentNode. appendChild (o) | null ;}
InsertAdjacentHTML = function (s, h ){
Var r = this. ownerDocument. createRange ();
R. setStartBefore (this );
This. insertAdjacentElement (s, r. createContextualFragment (h ));}
InsertAdjacentText = function (s, t ){
This. insertAdjacentElement (s, document. createTextNode (t ));}
}
// XMLDOM compatibility
Window. ActiveXObject = function (s ){
Switch (s ){
Case "XMLDom ":
Document. implementation. createDocument. call (this, "text/xml", "", null );
// DomDoc = document. implementation. createDocument ("text/xml", "", null );
Break;
}
}
XMLDocument. prototype. LoadXML = function (s ){
For (var I = 0, cs = this. childNodes, cl = childNodes. length; I <cl; I ++)
This. removeChild (cs [I]);
This. appendChild (this. importNode (new DOMParser (). parseFromString (s, "text/xml" ..doc umentElement, true ));}
XMLDocument. prototype. selectSingleNode = Element. prototype. selectSingleNode = function (s ){
Return this. selectNodes (s) [0];}
XMLDocument. prototype. selectNodes = Element. prototype. selectNodes = function (s ){
Var rt = [];
For (var I = 0, rs = this. evaluate (s, this, this. createNSResolver (this. ownerDocument = null? This.doc umentElement: this.ownerDocument.doc umentElement), XPathResult. ORDERED_NODE_SNAPSHOT_TYPE, null), sl = rs. snapshotLength; I <sl; I ++)
Rt. push (rs. snapshotItem (I ));
Return rt ;}
XMLDocument. prototype. _ proto _. _ defineGetter _ ("xml", function (){
Try {
Return new XMLSerializer (). serializeToString (this );}
Catch (e ){
Return document. createElement ("div"). appendChild (this. cloneNode (true). innerHTML ;}});
Element. prototype. _ proto _. _ defineGetter _ ("xml", function (){
Try {
Return new XMLSerializer (). serializeToString (this );}
Catch (e ){
Return document. createElement ("div"). appendChild (this. cloneNode (true). innerHTML ;}});
XMLDocument. prototype. _ proto _. _ defineGetter _ ("text", function (){
Return this. firstChild. textContent ;});
Element. prototype. _ proto _. _ defineGetter _ ("text", function (){
Return this. textContent ;});
Element. prototype. _ proto _. _ defineSetter _ ("text", function (s ){
Return this. textContent = s ;});
}