匿名用户
1级
2013-05-18 回答
我给你看下我自己写的一个计算器的代码吧!你要实现求和的话!必须要用javaScript,下面是代码内容:
计算器body{ background-color:buttonface; border-style:none;}
.button{ width:50px; height:30px;}
.button1{ width:90px; height:30px;}
#result{ width:100%; cursor:default; text-align:right;}
window.οnbefοreunlοad=function(){return("离开你会后悔的");void(0);
}function a(i){
switch(i){
case 11:i="/";break;
case 12:i="*";break;
case 13:i="-";break;
case 14:i="+";break;
case 15:i=".";break;
}
document.getElementById("result").value=document.getElementById("result").value+i;
} function calc(){
try{
document.getElementById("result").value = eval(document.getElementById("result").value);
}catch(e){
document.getElementById("result").value = "错误的算式";
}
}