Firefox兼容性問題

1、firefox不支持innerText,outerText,outerHTML

解決思路:a)用innerHTML替換innerText

    b)爲Firefox擴展innerText屬性,詳細參考:Firefox 不支持 DOM 對象的 outerHTML、innerText、outerText 屬性(http://www.w3help.org/zh-cn/causes/SD9017)


2、firefox不支持onfocusin,onfocusout

參考:http://help.dottoro.com/ljggspvo.php

http://stackoverflow.com/questions/13516931/prevent-cursor-moving-on-text-input


 

Instead of onfocus rather use onfocusin, that'll make your code to work.

EDIT

I just realized, that there is no focusin in Firefox. Hence you need something heavier.

The script:

function changeValueOnFocus (e, elm) {
        elm = elm || this;
        elm.value = 1234;
        return;  
}

window.onload = function () {
    if (window.onfocusin === undefined) {
        document.getElementById('someinput').addEventListener('focus', changeValueOnFocus, false);
    }
    return;
}

and for input you'll need an id:

<input id="someinput" maxlength="5" onfocusin="changeValueOnFocus(event, this);" type="text" />

Now this supposed to be a cross-browser solution.


accepte3


3、firefox不支持document.all

在對radio input進行操作時,會用到document.all來選擇某個值,比如:

document.all["carType"][0].checked = true;

但是在firefox裏不支持document.all,就可以用getElementsByName等來代替:

if (document.all) {
    			document.all["carType"][0].checked = true;
    		} else
    			document.getElementsByName("carType")[0].checked = true;



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章