我正在尝试动态地向具有两个单选框的页面添加一个选择框,但是Firefox的行为很奇怪。虽然第一个单选按钮明确定义为已选中,但在刷新页面时选择了更改(使用F5)。
完整的html是(查看here):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
<form>
<div id="txt0"></div>
<input value="10" type="radio" name="a" checked="checked">
<input value="11" type="radio" name="a">
</form>
<script type="text/javascript">
window.onload = function(){
document.getElementById('txt0').innerHTML = '<select name="sa"></select>';
};
</script>
</body>
</html>
答案 0 :(得分:2)
它看起来像某种缓存问题。做了一些测试:
checked
或checked=true
无效document.forms[0].a[0].checked = 'checked'
worked
(doh!)无论如何,它是recognised Firefox problem,所以你唯一能做的就是使用上面找到的解决方法之一,等到ff解决它。