Firefox中的禁用选项错误 [英] Disabled option in Firefox bug

查看:103
本文介绍了Firefox中的禁用选项错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Firefox中看到的时候创建了一些表单。在选择框中,如果您添加了已停用的选项作为首选...则选择下一个可用选项

 < option disabled =disabledvalue =false>选择选项< / option> 
< option value =1>值1< / option>

当页面加载时将选择值1。



为什么每个浏览器都会默认选择禁用的Firefox,而不是Firefox?



在Firefox中加载: a href =http://jsfiddle.net/6WjgZ/1/ =nofollow> http://jsfiddle.net/6WjgZ/1/


$ b $

解决方案

和其他浏览器,您会注意到Firefox绕过禁用的一个,并选择值1 p>假设您想要一个解决方法,请在DOM Load(或正文载入)上运行此代码以修复Firefox

 文档。 getElementById(mySel)。selectedIndex = 0; 

http://jsfiddle.net/6WjgZ/2/



不确定这是否可以称为错误(更多的行为风格) ,如果你想到它,FF不让你选择禁用项目。其他浏览器(IE除外)也没有,但是对于初始加载,它们选择不同的行为。


I was creating some form when I saw that in Firefox. In a select box, if you add a disabled option as first choice... it select the next available option

<option disabled="disabled" value="false">Choose option</option>
<option value="1">Value 1</option>

It will select "Value 1" when the page is loaded.

Why every browser will select the disabled one by default and Firefox not?

Load this in Firefox : http://jsfiddle.net/6WjgZ/1/

and other browser you'll notice that Firefox bypass the disabled one and select the "Value 1" by default.

解决方案

Assuming you want a workaround, run this code on DOM Load (or body load) to fix it in Firefox

document.getElementById("mySel").selectedIndex = 0;

http://jsfiddle.net/6WjgZ/2/

Not sure if this can be called a bug (more of a behavior style), if you think about it, FF doesn't let you choose disabled items. Neither does other browsers (except IE) but then, they choose to behave differently for the initial load.

这篇关于Firefox中的禁用选项错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆