当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 在修改准备发的批量美化select+可修改select时,在非IE下发现了几个问题

Javascript
Add a Table to a Word Document
Add Formatted Text to a Word Document
用jscript实现新建word文档
用jscript实现新建和保存一个word文档
Open and Print a Word Document
Use Word to Search for Files
Convert Seconds To Hours
Sample script that deletes a SQL Server database
Sample script that displays all of the users in a given SQL Server DB
firefox中用javascript实现鼠标位置的定位
div+css实现鼠标放上去,背景跟图片都会变化。
Locate a File Using a File Open Dialog Box
Save a File Using a File Save Dialog Box
用jscript实现列出安装的软件列表
List the Stored Procedures in a SQL Server database
Display SQL Server Login Mode
Display SQL Server Version Information
List all the Databases on a SQL Server
用jscript启动sqlserver
Stop SQL Server

Javascript 中的 在修改准备发的批量美化select+可修改select时,在非IE下发现了几个问题


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-10   浏览: 360 ::
收藏到网摘: n/a

发现的问题可能会陆续添加
1. Mozilla和Opera都不支持该字体,改掉DTD也是没有效果。测试在Mozilla Firefox1.5, Opera9.0下都是显示成Arial字体。而特殊符号是支持的。
如:
<body id="www.never-online.net">
<div style="font-family:Webdings">6</div>
<div>▼</div>
</body>
可以在不同浏览器打开,就可以看到区别了,以前不常用Webdings字体,现在才发现这个问题,所以以后还是用图片做这些比较好了。
2. 在IE和Opera中添加select控件的option,可以这样
<select id="sel">
</select>
<script type="text/javascript">
//<![CDATA[
var a=document.getElementById("sel");
var o=new Option("never-online.net","a",false,false);
a.add(o);
//]]>
</script>
但是在Mozilla下是失败的,将抛出异常。如果在Mozilla中动态添加select控件的Option呢?只需要这样
<select id="sel">
</select>
<script type="text/javascript">
//<![CDATA[
var a=document.getElementById("sel");
var o=new Option("never-online.net","a",false,false);
a.options.add(o);
//]]>
</script>
a.options.add(o);这句意思是不像在IE中可直接在select控件对象上添加option,而要在options对象上添加option,因此也可以从这一点看出Mozilla中要求写代码很严格。
3.同样的,在删除时,用remove方法,但不同的是不在options对象上删除option,而是在select控件对象上做的操作。代码
<select id="sel">
</select>
<script type="text/javascript">
//<![CDATA[
var a=document.getElementById("sel");
var o=new Option("never-online","a",false,false);
a.options.add(o);
alert("你可以看到添加了never-online这个option");
a.remove(0);
alert("现在删除添加的option");
//]]>
</script>