<!doctype html "> <head> <meta charset="uttf-8"> <title> new document </title> </head> <body> <input type="button" value="button" onClick="close()"> </body> <script type="text/javascript">var times;var fn=function(){alert("java");times=setTimeout(fn,2000);};var close=function(){clearTimeout(times);}fn();</script></html>浏览器提示的错误HTML 文档使用 meta 标签声明了一个不支持的字符编码。该声明被忽略。改了还是不行关闭不了
3 回答
已采纳
stone310
TA贡献361条经验 获得超191个赞
第一、<!doctype html ">这里多了个引号
第二、停止代码不能用close这个名字,close()是一个默认方法,这里close换成其他名字,如:stopTime()
Tobey_滔
TA贡献242条经验 获得超128个赞
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title> new document </title>
</head>
<body>
<input type="button" value="button" onClick="close()">
</body>
<script type="text/javascript">
var times;
var fn=function(){
alert("java");
times=setTimeout(fn,2000);
};
var close=function(){
clearTimeout(times);
}
fn();
</script>
</html>添加回答
举报
0/150
提交
取消
