简体   繁体   English

在Mozilla firefox和google-chrome中,“评估”不能作为javascript函数名称使用

[英]“Evaluate” doesn't work as a javascript function name in Mozilla firefox and google-chrome

I wrote a simple html file with just a javascript function. 我写了一个只有javascript函数的简单html文件。 It worked in IE but not in frefox and chrome. 它适用于IE,但不适用于frefox和chrome。 The code was: 代码是:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head>
<title>test</title>
<script type="text/javascript">
function evaluate()
{
alert("Hello World!");
}
</script>
</head>
<body>

<form >
<table id="tbl">
 <tr align="right">
  <td><input  id="__JAVA_Evaluate" type="button" value="evaluate!" onclick="evaluate()"/>
  </td>
 </tr>
</table>
</form>
</body>
</html>

After a while I understood that it was not possible to define a function with the name evaluate() in the Firefox and chrome. 一段时间后,我了解到无法在Firefox和chrome中定义名称为评价()的函数。 And it is enough to rename the function. 重命名功能就足够了。 I wonder that is other function name which are reserved in Firefox and chrome and how we could be aware about this reserved keys? 我想知道这是在Firefox和chrome中保留的其他函数名称,我们如何知道这个保留键?

Here is the reference for this function: 这是此功能的参考:

https://developer.mozilla.org/en/DOM/document.evaluate https://developer.mozilla.org/en/DOM/document.evaluate

Interesting that global functions and properties are not listed in Mozilla's official reserved word list: 有趣的是, 全局功能和属性未在Mozilla的官方保留字列表中列出:

https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words

Absolutely don't use any variables or function names that are in either of the previous lists. 绝对不要使用上述任何一个列表中的任何变量或函数名。 As you found, there may be additional peculiarities per-browser. 如您所见,每个浏览器可能还有其他特性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Javascript在Mozilla Firefox中不起作用 - Javascript doesn't work in Mozilla Firefox 我的脚本无法在Mozilla Firefox上运行,但可以在Chrome上运行 - My scripts doesn't work on Mozilla Firefox but does on Chrome 与Google Chrome相比,Mozilla Firefox中的JavaScript排序功能输出有所不同 - JavaScript Sort function Output is different in Mozilla Firefox Compared to Google Chrome window.onload功能在Mozilla Firefox上不起作用 - window.onload function doesn't work on Mozilla Firefox Java代码可在Mozilla Firefox中运行,但不能在Google Chrome中运行 - Javascript code working in Mozilla Firefox but not in Google Chrome 我的“ changeColor” JavaScript函数无法在Google Chrome浏览器上使用 - My “changeColor” javascript function doesn't work on Google Chrome collpase在mozilla中不起作用,但在chrome中起作用 - collpase doesn't work in mozilla but works in chrome 某些Javascript功能和标记在Chrome中不起作用,但在Mozilla Firefox中却可以正常工作。 帮助我吗? - Some Javascript Function and Tag Not Working In Chrome,but Its Work Good In Mozilla Firefox. Help Me Out Of These? 使用Flex 4.6在Mozilla Firefox或Google Chrome上关闭浏览器不起作用 - Closing Browser not work on Mozilla Firefox or Google Chrome using Flex 4.6 Google图表在Mozilla中不起作用 - Google chart doesn't work in mozilla
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM