生活随笔
收集整理的這篇文章主要介紹了
一个比较简单、非常简单的计算器
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
<html>???<head>??????????<title>計算公式</title>??????????<meta?http-equiv="pragma"?content="no-cache">?????<meta?http-equiv="cache-control"?content="no-cache">?????<meta?http-equiv="expires"?content="0">?????????<meta?http-equiv="keywords"?content="keyword1,keyword2,keyword3">?????<meta?http-equiv="description"?content="This?is?my?page">?????<script?type="text/javascript">?????????function?SumF(val){?????????????try{?????????????????if(val.indexOf("+")!=?-1?||?val.indexOf("-")!=?-1?||??????????????????????????val.indexOf("*")!=?-1?||?val.indexOf("/")!=?-1?||??????????????????????????val.indexOf("(")!=?-1?||?val.indexOf(")")!=?-1)??????????????????????document.getElementById("tes2").value?=?eval("("+val+")")?;????????????????}catch(err){??????????????????txt="表達式中存在錯誤。\n\n";????????????????txt+="錯誤描述:"?+?err.description?+?"\n\n";????????????????????txt+="點擊“確定”繼續。\n\n";??????????????????//alert(txt);???????????????}???????????}?????</script>???</head>?????<body>?????計算公式:<input?type="text"?onkeyup="SumF(this.value);"?id="tes1"?name="tes1"?/>???????計算結果:<input?type="text"?id="tes2"?name="tes2"?readonly="readonly"/>??????</body>?</html>? 一個網友的需求~~~做出來、瞬間感覺javaScript很強大!!!
轉載于:https://blog.51cto.com/hzw2312/752051
總結
以上是生活随笔為你收集整理的一个比较简单、非常简单的计算器的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。