<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>js消息模式对话框函数</title>
<script>
function input()
{
if(confirm("是否确定判断分数?")===true)
var str=prompt("");
if(str){
alert(s());
}
else
alert("");
}
function s(){
var score;
if (score <= 100 && score > 90) {
alert("高手高手,佩服佩服!");
} else if (score > 80) {
alert("8错,8错!");
} else if (score > 70) {
alert("凑合,凑合!");
} else if (score > 60) {
alert("勉强及格!");
} else {
alert("恭喜你,挂了!");
}
}
</script>
</head>
<body>
<p><a href="#" id="text1" onclick="input()">点此进入判断</a> </p>
</body>
</html>
因为你score没赋值,所以它只能走else
function input()
{
if(confirm("是否确定判断分数?")===true)
var str=prompt("");
if(str){
alert(s());
}
else
alert("");
}
function s(){
var score = prompt("请输入分数");
if (score <= 100 && score > 90) {
alert("高手高手,佩服佩服!");
} else if (score > 80) {
alert("8错,8错!");
} else if (score > 70) {
alert("凑合,凑合!");
} else if (score > 60) {
alert("勉强及格!");
} else {
alert("恭喜你,挂了!");
}
}