Firefox兼容性问题

本文讨论了Firefox浏览器中对于DOM特性如innerText、outerText、outerHTML、onfocusin、onfocusout及document.all的支持问题,并提供了替代方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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;



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值