JScript 有许多保留字,它们在 JScript 语言语法中有特定的意义。因此,这些字不宜作为脚本中的函数、变量或常数的名称。总共有三类保留字。受保护的保留字
break case catch class const 
continue debugger default delete do 
else export extends false finally 
for function if import in 
instanceof new null protected return 
super switch this throw true 
try typeOf var while with 受保护的保留字不能用作标识符。将受保护的保留字用作标识符会在加载脚本时引起编译错误。注意   尽管“export”是一个受保护的保留字,但它没有实现方法。
新保留字
abstract boolean byte char decimal 
double enum final float get 
implements int interface internal long 
package private protected public sbyte 
set short static uint ulong 
ushort void       JScript 还有一系列新保留字。像受保护的保留字一样,这些关键字在当前版本的 JScript 内有着特殊的意义。由于向后兼容的原因,新保留字可用作标识符。一旦将新保留字用作标识符,它就失去了作为脚本中关键字的意义。将新保留字用作标识符会引起混淆,应予以避免。未来保留字
assert ensure event goto invariant 
namespace native require synchronized throws 
transient use volatile     JScript 有一系列未来保留字,这些保留字将被建议用作 JScript 的未来扩展中的关键字。像新保留字一样,这些保留字也可以在当前版本的 JScript 中用作标识符。然而,若避免使用这些字,则在更新脚本以利用未来版本的 JScript 中的功能时会更为方便。在选择标识符时,避免选择已经是内部 JScript 对象或函数的名称(比如 String 或 parseInt)也是非常重要的

解决方案 »

  1.   

    chinchy兄的资料很好,但是也没有add这个保留字呀!
    而且第二个按钮也工作正常呀!
      

  2.   

    MSDN Home >  MSDN Library >  Web Development >  HTML and Dynamic HTML >  Reference >  Methods  
    add Method  Internet Development Index --------------------------------------------------------------------------------Adds an element to the areas, controlRange, or options collection.Syntaxobject.add(oElement [, iIndex])
    ParametersoElement Required. Object that specifies the element to add to the collection. 
    iIndex Optional. Integer that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection.  Return ValueNo return value.ResBefore you can add an element to a collection, you must create it first by using the createElement method.This method can be used to add elements only after the page loads.If the method is applied inline, a run-time error occurs.ExampleThis example uses the add method to insert an object into the options collection of a select object.<SELECT ID="oSelect">
      <OPTION VALUE="1">One</OPTION>
    </SELECT><SCRIPT>
    var oOption = document.createElement("OPTION");
    oSelect.options.add(oOption);
    oOption.innerText = "Two";
    oOption.value = "2";
    </SCRIPT>
    Standards InformationThis method is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 . Applies To[ Object Name ] 
    Platform Version 
    Win16:  
    Win32:  
    Windows CE:  
    Unix:  
    Mac:  
    Version data is listed when the mouse hovers over a link, or the link has focus. 
     areas, controlRange, options, SELECT 
    Move the mouse pointer over an element in the Applies To list to display availability information for the listed platforms. See Alsoremove 
      

  3.   

    就算add是IE中关键字,为什么第二个按钮能正确执行?
      

  4.   

    我觉得,是你的“函数名称”跟button的名称冲突的缘故
      

  5.   

    loku兄是不是说有两个button的id都是add呀?不是这个问题啊。
    不信你把第二个button的id改为add1,第一个按钮还是错误。
      

  6.   

    嗨,天天被Javascript折磨,有没有哪个编辑工具有javascript属性和方法的提示呀,就像Dreamweaver对html有提示一样?
      

  7.   

    <script language="javascript">
    function add(){
     alert("add");
    }
    </script><body>
    <form>
    <input type="button" id="add1" value="Add" onClick="add()" />
    </form>
    <input type="button" id="add2" value="Add" onClick="add()" />input对象不能当数组对象用
      

  8.   

    我试了,就是form中ID号与函数名一样导致的问题,form外的没关系
      

  9.   

    id=add
    两个button使用同一个id是不允许的.
    <html>
    <head>
    <script language="javascript">
    function add(){
     alert("add");
    }
    </script>
    </head>
    <body>
    <form>
    <input type="button" id="add1" value="Add" onClick="add()" />
    <input type="button" id="add2" value="Add" onClick="add()" />
    </form>
    </body>
    </html>
      

  10.   

    正像钻石里的泡泡说的那样,不是关键字的问题。form中的id不能和函数名称相同。好了,明天结贴。