乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      FF與IE對(duì)javascript和CSS的區(qū)別

       WindySky 2009-03-19

      1. document.formName.item("itemName") 問(wèn)題
      說(shuō)明:IE下,可以使用document.formName.item("itemName")或document.formName.elements["elementName"];
      Firefox下,只能使用document.formName.elements["elementName"].
      解決方法:統(tǒng)一使用document.formName.elements["elementName"].

      2.集合類對(duì)象問(wèn)題
      說(shuō)明:IE下,可以使用()或[]獲取集合類對(duì)象;Firefox下,只能使用[]獲取集合類對(duì)象.
      解決方法:統(tǒng)一使用[]獲取集合類對(duì)象.

      3.自定義屬性問(wèn)題
      說(shuō)明:IE下,可以使用獲取常規(guī)屬性的方法來(lái)獲取自定義屬性,也可以使用getAttribute()獲取自定義屬性;Firefox下,只能使用getAttribute()獲取自定義屬性.
      解決方法:統(tǒng)一通過(guò)getAttribute()獲取自定義屬性.

      4.eval("idName")問(wèn)題
      說(shuō)明:IE下,,可以使用eval("idName")或getElementById("idName")來(lái)取得id為idName的HTML對(duì)象;Firefox下只能使用getElementById("idName")來(lái)取得id為idName的HTML對(duì)象.
      解決方法:統(tǒng)一用getElementById("idName")來(lái)取得id為idName的HTML對(duì)象.

      5.變量名與某HTML對(duì)象ID相同的問(wèn)題
      說(shuō)明:IE下,HTML對(duì)象的ID可以作為document的下屬對(duì)象變量名直接使用;Firefox下則不能.Firefox下,可以使用與HTML對(duì)象ID相同的變量名;IE下則不能。
      解決方法:使用document.getElementById("idName")代替document.idName.最好不要取HTML對(duì)象ID相同的變量名,以減少錯(cuò)誤;在聲明變量時(shí),一律加上var,以避免歧義.

      6.const問(wèn)題
      說(shuō)明:Firefox下,可以使用const關(guān)鍵字或var關(guān)鍵字來(lái)定義常量;IE下,只能使用var關(guān)鍵字來(lái)定義常量.
      解決方法:統(tǒng)一使用var關(guān)鍵字來(lái)定義常量.

      7.input.type屬性問(wèn)題
      說(shuō)明:IE下input.type屬性為只讀;但是Firefox下input.type屬性為讀寫.

      8.window.event問(wèn)題
      說(shuō)明:window.event只能在IE下運(yùn)行,而不能在Firefox下運(yùn)行,這是因?yàn)镕irefox的event只能在事件發(fā)生的現(xiàn)場(chǎng)使用. Firefox必須從源處加入event作參數(shù)傳遞。Ie忽略該參數(shù),用window.event來(lái)讀取該event。
      解決方法:
      IE&Firefox:
      Submitted(event)"/> …

      1. <script language="javascript">   
      2. function Submitted(evt) {   
      3. evt=evt?evt:(window.event?window.event:null);   
      4. }   
      5. </script>  

       
      9.event.x與event.y問(wèn)題
      說(shuō)明:IE下,even對(duì)象有x,y屬性,但是沒(méi)有pageX,pageY屬性;Firefox下,even對(duì)象有pageX,pageY屬性,但是沒(méi)有x,y屬性.
      解決方法:使用mX(mX = event.x ? event.x : event.pageX;)來(lái)代替IE下的event.x或者Firefox下的event.pageX.

      10.event.srcElement問(wèn)題
      說(shuō)明:IE下,event對(duì)象有srcElement屬性,但是沒(méi)有target屬性;Firefox下,even對(duì)象有target屬性,但是沒(méi)有srcElement屬性.
      解決方法:使用obj(obj = event.srcElement ? event.srcElement : event.target;)來(lái)代替IE下的event.srcElement或者Firefox下的event.target. 請(qǐng)同時(shí)注意event的兼容性問(wèn)題。

      11.window.location.href問(wèn)題
      說(shuō)明:IE或者Firefox2.0.x下,可以使用window.location或window.location.href;Firefox1.5.x下,只能使用window.location.
      解決方法:使用window.location來(lái)代替window.location.href.

      12.模態(tài)和非模態(tài)窗口問(wèn)題
      說(shuō)明:IE下,可以通過(guò)showModalDialog和showModelessDialog打開(kāi)模態(tài)和非模態(tài)窗口;Firefox下則不能.
      解決方法:直接使用window.open(pageURL,name,parameters)方式打開(kāi)新窗口。
      如果需要將子窗口中的參數(shù)傳遞回父窗口,可以在子窗口中使用window.opener來(lái)訪問(wèn)父窗口. 例如:var parWin = window.opener; parWin.document.getElementById("Aqing").value = "Aqing";

      13.frame問(wèn)題
      以下面的frame為例:
      <frame xsrc="xxx.html" id="frameId" name="frameName" />
      (1)訪問(wèn)frame對(duì)象:
      IE:使用window.frameId或者window.frameName來(lái)訪問(wèn)這個(gè)frame對(duì)象. frameId和frameName可以同名。
      Firefox:只能使用window.frameName來(lái)訪問(wèn)這個(gè)frame對(duì)象.
      另外,在IE和Firefox中都可以使用window.document.getElementById("frameId")來(lái)訪問(wèn)這個(gè)frame對(duì)象.
      (2)切換frame內(nèi)容:
      在IE和Firefox中都可以使用window.document.getElementById("testFrame").src = "xxx.html"或window.frameName.location = "xxx.html"來(lái)切換frame的內(nèi)容.
      如果需要將frame中的參數(shù)傳回父窗口(注意不是opener,而是parent frame),可以在frme中使用parent來(lái)訪問(wèn)父窗口。例如:parent.document.form1.filename.value="Aqing";

      14.body問(wèn)題
      Firefox的body在body標(biāo)簽沒(méi)有被瀏覽器完全讀入之前就存在;而IE的body則必須在body標(biāo)簽被瀏覽器完全讀入之后才存在.

      15. 事件委托方法
      IE:document.body.onload = inject; //Function inject()在這之前已被實(shí)現(xiàn)
      Firefox:document.body.onload = inject();

      16. firefox與IE的父元素(parentElement)的區(qū)別
      IE:obj.parentElement
      firefox:obj.parentNode
      解決方法: 因?yàn)閒irefox與IE都支持DOM,因此使用obj.parentNode是不錯(cuò)選擇.

      17.cursor:hand VS cursor:pointer
      firefox不支持hand,但ie支持pointer
      解決方法: 統(tǒng)一使用pointer

      18.innerText在IE中能正常工作,但是innerText在FireFox中卻不行. 需用textContent。
      解決方法:

      Js代碼 復(fù)制代碼
      1. if(navigator.appName.indexOf("Explorer") > -1){   
      2.     document.getElementById('element').innerText = "my text";   
      3. else{   
      4.     document.getElementById('element').textContent = "my text";   
      5. }  

       
      19. FireFox中設(shè)置HTML標(biāo)簽的style時(shí),所有位置性和字體尺寸的值必須后跟px。這個(gè)ie也是支持的。

      20. ie,firefox以及其它瀏覽器對(duì)于 table 標(biāo)簽的操作都各不相同,在ie中不允許對(duì)table和tr的innerHTML賦值,使用js增加一個(gè)tr時(shí),使用appendChild方法也不管用。
      解決方法:
      //向table追加一個(gè)空行:

      Js代碼 復(fù)制代碼
      1. var row = otable.insertRow(-1);   
      2. var cell = document.createElement("td");   
      3. cell.innerHTML = " ";   
      4. cell.className = "XXXX";   
      5. row.appendChild(cell);  


      21. padding 問(wèn)題
      padding 5px 4px 3px 1px FireFox無(wú)法解釋簡(jiǎn)寫,
      必須改成 padding-top:5px; padding-right:4px; padding-bottom:3px; padding-left:1px;

      22. 消除ul、ol等列表的縮進(jìn)時(shí)
      樣式應(yīng)寫成:list-style:none;margin:0px;padding:0px;
      其中margin屬性對(duì)IE有效,padding屬性對(duì)FireFox有效

      23. CSS透明
      IE:filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=60)。
      FF:opacity:0.6。

      24. CSS圓角
      IE:不支持圓角。
      FF: -moz-border-radius:4px,或者-moz-border-radius-topleft:4px;-moz-border- radius-topright:4px;-moz-border-radius-bottomleft:4px;-moz-border- radius- bottomright:4px;。

      25. CSS雙線凹凸邊框
      IE:border:2px outset;。
      FF: -moz-border-top-colors: #d4d0c8 white;-moz-border-left-colors: #d4d0c8 white;-moz-border-right-colors:#404040 #808080;-moz-border-bottom-colors:#404040 #808080;

      26. 對(duì)select的options集合操作
      枚舉元素除了[]外,SelectName.options.item()也是可以的, 另外SelectName.options.length, SelectName.options.add/remove都可以在兩種瀏覽器上使用。注意在add后賦值元素,否則會(huì)失?。ū救嗽囼?yàn)如此)。

      27. XMLHTTP的區(qū)別

      Js代碼 復(fù)制代碼
      1. //mf   
      2. if (window.XMLHttpRequest) //mf   
      3. {   
      4. xmlhttp=new XMLHttpRequest()   
      5. xmlhttp.   
      6. xmlhttp.open("GET",url,true)   
      7. xmlhttp.send(null)   
      8. }   
      9. //ie   
      10. else if (window.ActiveXObject) // code for IE   
      11. {   
      12. xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")   
      13.     if (xmlhttp)   
      14.     {   
      15.     xmlhttp.   
      16.     xmlhttp.open("GET",url,true)   
      17.     xmlhttp.send()   
      18.     }   
      19. }   
      20. }  


      28. innerHTML的區(qū)別
      Firefox不支持innerHTML, 解決辦法可以如下

      Js代碼 復(fù)制代碼
      1. rng = document.createRange();   
      2. el = document.getElementById(elementid);   
      3. rng.setStartBefore(el);   
      4. htmlFrag = rng.createContextualFragment(content);   
      5. while (el.hasChildNodes()) //清除原有內(nèi)容,加入新內(nèi)容   
      6.        el.removeChild(el.lastChild);   
      7. el.appendChild(htmlFrag);  

       
      29. img的src刷新問(wèn)題
      在 IE下可以用<img id="pic" onclick= "this.src= 'aa.php'" xsrc="aa.php" style="cursor: pointer"/> 可以刷新圖片,但在FireFox下不行。主要是緩存問(wèn)題,在地址后面加個(gè)隨機(jī)數(shù)就解決了。編輯onclick事件代碼如下: "this.src=this.src+'?'+Math.random()"

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多