<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
window.onload = function (){
function fn1(){
var str;
str = prompt("请输入你的成绩");
if(str >= 80){
document.write("不错很牛逼");
}else{
document.write("加油!");
}
};
}
</script>
</head>
<body>
<input type="button" value="点击我,验证你的成绩是否合格!" onclick="fn1()" />
</body>
</html>
上面这个函数,我在按钮中添加点击事件的时候,显示fn1 未定义,这是怎么回事啊 ?
stone310
相关分类