runxinzhi.com
首页
百度搜索
网页计数器
<html> <head> <title>计算器</title> </head> <body bgcolor="#33FF99" onload="FKeyPad.ReadOut.focus();FKeyPad.ReadOut.select();"> <FORM name="Keypad" action=""> <TABLE align="center"> <B> <TABLE align="center" border=3 width=60 height=80 cellpadding=2 cellspacing=5 borderlight="#008080"> <tr align="center"> <td bordercolor="#FF33CC" bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933" colspan=10 align=center>网页计算器</td> </tr> <tr align="center"> <td bordercolor="#FF33CC" bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933" colspan=10 align=right><input name="ReadOut" type="Text" onkeypress="CheckOut()" size=40 value="0" width=100%></td> </tr> <tr align="center"> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnsin" type="Button" value=" sin " onclick="useFun ('sin')"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btncos" type="Button" value=" cos " onclick="useFun ('cos')"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnOne" type="Button" value=" 1 " onclick="NumPressed(1)"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnTwo" type="Button" value=" 2 " onclick="NumPressed(2)"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnThree" type="Button" value=" 3 " onclick="NumPressed(3)"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnPlus" type="Button" value=" + " onclick="Operation('+')"> </td> </tr> <tr align="center"> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnasin" type="Button" value=" asin " onclick="useFun ('asin')"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnacos" type="Button" value=" acos " onclick="useFun ('acos')"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnFour" type="Button" value=" 4 " onclick="NumPressed(4)"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnFive" type="Button" value=" 5 " onclick="NumPressed(5)"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnSix" type="Button" value=" 6 " onclick="NumPressed(6)"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnMinus" type="Button" value=" - " onclick="Operation('-')"></td> </tr> <tr align="center"> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btntan" type="Button" value=" tan " onclick="useFun ('tan')"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnatan" type="Button" value=" atan " onclick="useFun ('atan')"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnSeven" type="Button" value=" 7 " onclick="NumPressed(7)"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnEight" type="Button" value=" 8 " onclick="NumPressed(8)"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnNine" type="Button" value=" 9 " onclick="NumPressed(9)"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnMultiply" type="Button" value=" * " onclick="Operation('*')"></td> </tr> <tr align="center"> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnlog" type="Button" value=" log " onclick="useFun ('log')"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnexp" type="Button" value=" exp " onclick="useFun ('exp')"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnZero" type="Button" value=" 0 " onclick="NumPressed(0)"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnDecimal" type="Button" value=" . " onclick="Decimal()"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnNeg" type="Button" value=" +/- " onclick="Neg()"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnDivide" type="Button" value=" / " onclick="Operation('/')"></td> </tr> <tr align="center"> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnsqrt" type="Button" value=" sqrt " onclick="useFun ('sqrt')"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnOx" type="Button" value=" 1/x " onclick="useFun ('1/x')"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnXt" type="Button" value=" x^2 " onclick="useFun ('x^2')"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnXthr" type="Button" value=" x^3 " onclick="useFun ('x^3')"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnpi" type="Button" value=" pi " onclick=FKeyPad.ReadOut.value=Math.PI></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnEquals" type="Button" value=" = " onclick="Operation('=')"></td> </tr> <tr align="center"> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnDivide" type="Button" value=" N! " onclick="ni ()"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnDivide" type="Button" value=" pow " onclick="Operation('pow')"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnDivide" type="Button" value=" E " onclick=FKeyPad.ReadOut.value=Math.E></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnClear" type="Button" value=" C " onclick="Clear()"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnClearEntry" type="Button" value=" CE " onclick="ClearEntry()"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnReturn" type="Button" value="返 回" onclick="goReturn()"></td> </tr> <tr align="center"> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnmod" type="Button" value=" MOD " onclick="Operation('MOD')"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnDivide" type="Button" value=" INT" onclick=FKeyPad.ReadOut.value=parseInt(FKeyPad.ReadOut.value,10)></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnmod" type="Button" value=" HEX " onclick="hexchange ()"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnmod" type="Button" value=" OCT " onclick="octchange ()"></td> <td bordercolordark="#cc0066" bordercolor="#FF9966" bordercolorlight="#CC9933"><input name="btnmod" type="Button" value=" BIN " onclick="binchange ()"></td> </tr> </TABLE> </TABLE> </B> </FORM> </CENTER> <font face="Verdana, Arial, Helvetica" size=2> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin var FKeyPad = document.forms['Keypad']; var Accum = "0"; var FlagNewNum = false; var PendingOp = ""; function longCount(str1,str2,type) { var comma1 = 0; if (str1.indexOf(".")!=-1) { str1 = str1.replace(/0*$/,""); comma1 = str1.length - str1.indexOf(".")-1; } var comma2 = 0; if (str2.indexOf(".")!=-1) { str2 = str2.replace(/0*$/,""); comma2 = str2.length - str2.indexOf(".")-1; } str1 = str1.replace(//./,""); str2 = str2.replace(//./,""); var value,comma; if (type!="*") { if (comma1>comma2) { for (var i=0;i<comma1-comma2;i++) str2 += "0"; comma = (type=="/")?0:comma1; }else { for (var i=0;i<comma2-comma1;i++) str1 += "0"; comma = (type=="/")?0:comma2; } }else { comma = comma1 + comma2; } if (type=="+") { value = parseInt(str1,10) + parseInt(str2,10); }else if (type=="-") { value = parseInt(str1,10) - parseInt(str2,10); }else if (type=="*") { value = parseInt(str1,10) * parseInt(str2,10); }else if (type=="/") { value = parseInt(str1,10) / parseInt(str2,10); } else if (type=="MOD") value = parseInt(str1,10) % parseInt(str2,10); else if (type=="pow") { var a,b,s=1; a=parseInt(str1,10); b=parseInt(str2,10); for(var i=1;i<=b;i++) s=s*a; value=parseInt(s,10); } value = String(value); if (comma>0) value = value.substring(0,value.length-comma)+"."+value.substring(value.length- comma,value.length); if (value.indexOf(".")!=-1) value = value.replace(/0*$/,""); return value; } function NumPressed (Num) { if (FlagNewNum) { FKeyPad.ReadOut.value = Num; FlagNewNum = false; } else { if (FKeyPad.ReadOut.value == "0") FKeyPad.ReadOut.value = Num; else FKeyPad.ReadOut.value += Num; } } function Operation (Op) { var Readout = FKeyPad.ReadOut.value; if (FlagNewNum && PendingOp != "="); else { FlagNewNum = true; if ( '+' == PendingOp || '-' == PendingOp || '/' == PendingOp || '*' == PendingOp||'MOD'==PendingOp||'pow'==PendingOp) Accum = longCount(Accum,Readout,PendingOp); else Accum = Readout; FKeyPad.ReadOut.value = Accum; PendingOp = Op; FKeyPad.ReadOut.focus(); FKeyPad.ReadOut.select(); } } function useFun (st) { switch(st) { case "sin": FKeyPad.ReadOut.value=Math.sin(FKeyPad.ReadOut.value); FlagNewNum=true; break; case "cos": FKeyPad.ReadOut.value=Math.cos(FKeyPad.ReadOut.value); FlagNewNum=true; break; case "asin": FKeyPad.ReadOut.value=Math.asin(FKeyPad.ReadOut.value); FlagNewNum=true; break; case "acos": FKeyPad.ReadOut.value=Math.acos(FKeyPad.ReadOut.value); FlagNewNum=true; break; case "tan": FKeyPad.ReadOut.value=Math.tan(FKeyPad.ReadOut.value); FlagNewNum=true; break; case "atan": FKeyPad.ReadOut.value=Math.atan(FKeyPad.ReadOut.value); FlagNewNum=true; break; case "log": FKeyPad.ReadOut.value=Math.log(FKeyPad.ReadOut.value); FlagNewNum=true; break; case "exp": FKeyPad.ReadOut.value=Math.exp(FKeyPad.ReadOut.value); FlagNewNum=true; break; case "sqrt": FKeyPad.ReadOut.value=Math.sqrt(FKeyPad.ReadOut.value); FlagNewNum=true; break; case "1/x": FKeyPad.ReadOut.value=1/FKeyPad.ReadOut.value; FlagNewNum=true; break; case "x^2": FKeyPad.ReadOut.value=parseFloat(FKeyPad.ReadOut.value)*parseFloat(FKeyPad.ReadOut.value); FlagNewNum=true; break; case "x^3": FKeyPad.ReadOut.value=parseFloat(FKeyPad.ReadOut.value)*parseFloat(FKeyPad.ReadOut.value)*parseFloat(FKeyPad.ReadOut.value); FlagNewNum=true; break; } } function hexchange () { var hex,dec; dec = parseFloat(FKeyPad.ReadOut.value); hex = dec.toString(16); window.alert("该十进制数转成十六进制数为:"+ hex); } function octchange () { var oct,dec; dec = parseFloat(FKeyPad.ReadOut.value); oct = dec.toString(8); window.alert("该十进制数转成八进制数为:"+ oct); } function binchange () { var bin,dec; dec = parseFloat(FKeyPad.ReadOut.value); bin = dec.toString(2); window.alert("该十进制数转成二进制数为:"+ bin); } function ni () {var y,k=1; y=parseFloat(FKeyPad.ReadOut.value); for(var x=1;x<=y;x++) k=k*x; FKeyPad.ReadOut.value=k; } function Decimal () { var curReadOut = FKeyPad.ReadOut.value; if (FlagNewNum) { curReadOut = "0."; FlagNewNum = false; } else { if (curReadOut.indexOf(".") == -1) curReadOut += "."; } FKeyPad.ReadOut.value = curReadOut; } function ClearEntry () { FKeyPad.ReadOut.value = "0"; FlagNewNum = true; } function Clear () { Accum = "0"; PendingOp = ""; ClearEntry(); } function Neg () { window.alert(FKeyPad.ReadOut.value); FKeyPad.ReadOut.value = longCount(FKeyPad.ReadOut.value,"-1","*"); } function goReturn() { top.returnValue = FKeyPad.ReadOut.value; self.close(); } function CheckOut() { var keyCode = window.event.keyCode; if (keyCode>=48 && keyCode<=57) { if (FlagNewNum) { FKeyPad.ReadOut.value = ""; FlagNewNum = false; } return true; }else if (keyCode==43 || keyCode==45 || keyCode==42 || keyCode==47 || keyCode==61) { Operation(String.fromCharCode(keyCode)); }else if (keyCode==46) { if (FKeyPad.ReadOut.value.indexOf(".") == -1) return true; }else if (keyCode==27) goReturn(); window.event.returnValue = false; return false; } // End --> </SCRIPT> <td class=tablebody2 width="28%" bgcolor="#2282B2" height="19" > <font color="#FFA34F" size="2"><b>来自 <a target="_blank" href="http://blog.csdn.net/kings1108"> <font color="#FFA34F">【谢宇帆博客】 </font></a></b> </font> </td> </body> </html>
相关阅读:
day39
day36
day35
day34
深入理解css的margin
git使用
java常见的分页实现方式
jquery常识
与border不得不说的故事
测试效果
原文地址:https://www.cnblogs.com/Fandyx/p/2761465.html
最新文章
13
hdfs、zookeepeer之HA模式
Hadoop之集群搭建
Maven快速入门
排序算法总结(java实现)
关于图片的像素类问题
Python字符串拼接
虚拟机上Linux无法连接外网问题
计算机网络面试
走进NoSql大世界
热门文章
java核心基础
数据库原理
VMware配置NAT方式下的静态ip
Redis入门简介
Python类中的特殊方法
day13
day14
day15
day16
day38
Copyright © 2020-2023
润新知