請問大神們 是否有其他寫法 這種寫法是否存在漏洞
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>prompt</title>
? <script type="text/javascript">
? function rec(){
var score; //score變量,用來存儲用戶輸入的成績值。
score =prompt("請輸入你的分數:");
if(score>100)
{
? ?document.write("滿分才100呢");
}
else if(score>=90)
{
? ? document.write("你很棒");
}
else if(score>=75)
? ? {
? ?document.write("不錯吆!");
}
else if(score>=60)
? ? {
? ?document.write("要加油!");
? ? }
? ? else if(score>=0)
{
? ? ? ?document.write("要努力了!");
}
else
{
? ? document.write("請不要胡亂輸入");
}
? }
? </script>
</head>
<body>
? ? <input name="button" type="button" onClick="rec()" value="點擊我,對成績做評價!" />
</body>
</html>
2021-03-02
?}
? ? else if(score>=0 && score != null && score != "")?
{
? ? ? ?document.write("要努力了!");
}
建議對空數據做處理,避免和0分混在一個分支里面;