2.IE下,可以使用()或[]獲取集合類對(duì)象;Firefox下,只能使用[]獲取集合類對(duì)象. 解決方法:統(tǒng)一使用[]獲取集合類對(duì)象. 3.IE下,可以使用獲取 " /> 东日韩二三区,一个人免费完整在线观看影院,男人扒开添女人屁股

天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

javascript firefox兼容ie的dom方法腳本

if(!document.all){
//zzcv的ff ie兼容腳本
/*腳本沒有解決的問題及處理:

2.IE下,可以使用()或[]獲取集合類對(duì)象;Firefox下,只能使用[]獲取集合類對(duì)象. 
解決方法:統(tǒng)一使用[]獲取集合類對(duì)象. 
3.IE下,可以使用獲取常規(guī)屬性的方法來獲取自定義屬性,也可以使用getAttribute()獲取自定義屬性;Firefox下,只能使用getAttribute()獲取自定義屬性. 
解決方法:統(tǒng)一通過getAttribute()獲取自定義屬性. 
4.IE下,HTML對(duì)象的ID可以作為document的下屬對(duì)象變量名直接使用;Firefox下則不能.
5.Firefox下,可以使用與HTML對(duì)象ID相同的變量名;IE下則不能。
解決方法:使用document.getElementById("idName")代替document.idName.最好不要取HTML對(duì)象ID相同的變量名,以減少錯(cuò)誤;在聲明變量時(shí),一律加上var,以避免歧義. 
6.IE下input.type屬性為只讀;但是Firefox下input.type屬性為讀寫. 
8.IE下,可以通過showModalDialog和showModelessDialog打開模態(tài)和非模態(tài)窗口;Firefox下則不能
9.Firefox的body在body標(biāo)簽沒有被瀏覽器完全讀入之前就存在;而IE的body則必須在body標(biāo)簽被瀏覽器完全讀入之后才存在
10.
*/
//文檔兼容
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];};

//事件兼容
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.target;});

    __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.target)||null;
        if(o)
            while(o.nodeType!=1)
                o=o.parentNode;
        return o;});

    __defineGetter__("toElement",function(){
        var o=(this.type=="mouseover"&&this.target)||(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;});
}
//節(jié)點(diǎn)操作兼容
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元素兼容
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兼容
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").documentElement,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.documentElement:this.ownerDocument.documentElement),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;});

}

JavaScript技術(shù)javascript firefox兼容ie的dom方法腳本,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 99无码熟妇丰满人妻啪啪 | 久久黄色录像 | 国产在线观看黄 | 中文文字幕文字幕亚洲色 | 免费麻豆国产黄网站在线观看 | 高h超辣bl文| 好姑娘BD高清在线观看免费 | 外国xxxx| 在线免费观看国产视频 | 被男按摩师添的好爽在线直播 | 校花娇喘呻吟校长陈若雪视频 | 久久伊人免费 | 久久免费高清 | 混乱家庭电影完整版在线看 | 牛牛在线国产精品 | 老师你奶真大下面水真多 | 你是淫荡的我的女王 | 双性将军粗壮H灌满怀孕 | 亚洲精品久久久午夜福利电影网 | 伊人久久综在合线亚洲 | 欧美5g影院天天爽天天看 | 欧美一夜爽爽爽爽爽爽 | 久久久欧美国产精品人妻噜噜 | 青青热久精品国产亚洲AV无码 | 日本艳妓BBW高潮一19 | 欧美特级午夜一区二区三区 | 国产成人精品综合久久久 | 毛片免费观看 | 亚洲高清毛片一区二区 | 伊人大香人妻在线播放 | 欧美午夜精品久久久久久浪潮 | 亚洲精品久久久一区 | 超碰v| 黄色三级视频网站 | 亚洲在线无码免费观看 | 老牛天天晚上夜噜噜噜 | 国产一区二区波多野结衣 | 亚洲蜜桃AV永久无码精品放毛片 | 国产精品高清视频在线 | 午夜伦理在线观看 | 色哟哟网站入口在线观看视频 |