<html>
<head>
<title>abc</title>
</head><body>
<input type = "text" onclick = "ClickMe();" />
<script>
function ClickMe()//onclick -->ClickMe
{
var i;
for(i=0;i<10;i++)
{
document.write(i);
}
}
</script></body>
</html>
<head>
<title>abc</title>
</head><body>
<input type = "text" onclick = "ClickMe();" />
<script>
function ClickMe()//onclick -->ClickMe
{
var i;
for(i=0;i<10;i++)
{
document.write(i);
}
}
</script></body>
</html>
是js关键字
请不要使用
case do if switch var
catch else in this void
continue false instanceof throw while
debugger finally new true with
default for null try
为将来保留的词
abstract double goto native static
boolean enum implements package super
byte export import private synchronized
char extends int protected throws
class final interface public transient
const float long short volatile 如果如楼上说,大概是我的资料旧了...
function anonymous() {
onclick();
}
即 onclick(); 事件拥有一个对缺省 anonymous() 函数的引用,而 onclick 又不能被同名函数所覆盖(否则事件机制就彻底报销了),因此结果就是“死循环”,栈溢出!结论:事件名虽然不是保留字,但是也不可以用于变量名或函数名!!!否则后果自负,哈
先看看是怎么死掉的就执行以下代码,不怕死的上:<html>
<head>
<title>abc</title>
</head><body>
<input type = "text" onclick = "alert(this.onclick);onclick();" />
<script>
function onclick()
{
alert("in");
var i;
for(i=0;i<10;i++)
{
document.write(i);
}
}
</script></body>
</html>
<head>
<title>abc</title>
</head><body>
<input type = "text" onclick = "alert(this.onclick);clickMe();" />
<script>
function clickMe()
{
alert("in");
var i;
for(i=0;i<10;i++)
{
document.write(i);
}
}
</script></body>
</html>