select在各浏览器中显示option的测试结果分享

2020-04-28 07:29:33易采站长站整理

</body>
</html>

测试结果:Chrome、Safari显示正常,Firefox、IE9、IE8、IE7、Opera下不能显示。
方法5
代码如下:


<html>
<head>
<title></title>
<script type=”text/javascript”>
function init()
{
var s = document.getElementById(“s”);
s.options[0] = new Option(“E”);
}
</script>
</head>
<body onload=”init()”>
<select id=”s” style=”width:100px;background:lightskyblue”></select>
</body>
</html>

测试结果:Firefox、Chrome、IE9、IE8、IE7、Safari、Opera显示正常。
方法6
代码如下:


<html>
<head>
<title></title>
<script type=”text/javascript”>
function init()
{
var s = document.getElementById(“s”);
var op = document.createElement(“option”);
op.appendChild(document.createTextNode(“F”));
s.appendChild(op);
}
</script>
</head>
<body onload=”init()”>
<select id=”s” style=”width:100px;background:lightskyblue”></select>
</body>
</html>

测试结果:Firefox、Chrome、IE9、IE8、IE7、Safari、Opera显示正常。
方法7
代码如下:


<html>
<head>
<title></title>
<script type=”text/javascript”>
function init()
{
var s = document.getElementById(“s”);
s.innerHTML = “<option>X</option><option>Y</option>”;
}
</script>
</head>
<body onload=”init()”>
<select id=”s” style=”width:100px;background:lightskyblue”></select>
</body>
</html>

测试结果:Firefox、Chrome、Safari、Opera显示正常,IE9、IE8、IE7下不能显示。