[英]“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.