一个自己写的网页计算器

xiaoxiao2021-02-28  53

<style type="text/css"> .style1{ width:60px; height:60px; text-align:center; } .style2{ border-style: inset; width: 340px; height:40px; cursor: auto;/*光标属性*/ top: 0px; left: 243px; overflow:auto; /*overflow 属性规定如何处理如何处理不符合元素框的内容。*/ resize:none; overflow-x:hidden; overflow-y:hidden } .style3{ /*text-align:"center";*/ border:1px red solid"; width:300px; height:240px; } .style3 input{ height:59px; width:59px; } .style4{ background-image:url(a.jpg); text-align:center; margin:0 auto; background-color:gray; width:360px; } #Buttonjia{ height:120px; width:59px; } </style> <script> var valueone=""; function Button_click(valuetwo){ valueone=valueone+valuetwo; document.getElementById("text").value=valueone; return true; } function Calculate(valuethree){ try{ document.getElementById("text").value=valueone+valuethree+eval(document.getElementById("text").value); }catch (excp) { document.getElementById("text").innerHTML = "<font color=\"red\">您输入的表达式有错误,请检查后重新计算!!!!</font>"; } return true; } function Removeall() { valueone= ""; document.getElementById("text").innerHTML = ""; return true; } var oLink = document.createElement(""); oLink.href = "#"; </script> <div class="style4" > <form > <div align=center> <textarea class="style2" id="text" name="text01" readonly="readonly"style="font-size:30px;margin:6px auto 2px auto;" ></textarea> </div> <table class="style3" align=center> <tr> <td class="style1"><input id="Button1" type="button" value="1"onclick="return Button_click('1')" /></td> <td class="style1"><input id="Button2" type="button" value="2"onclick="return Button_click('2')" /></td> <td class="style1"><input id="Button3" type="button" value="3"onclick="return Button_click('3')" /></td> <td class="style1"><input id="Button(" type="button" value="("onclick="return Button_click('(')" /></td> <td class="style1"><input id="Button)" type="button" value=")"onclick="return Button_click(')')" /></td> </tr> <tr> <td class="style1"><input id="Button4" type="button" value="4"onclick="return Button_click('4')" /></td> <td class="style1"><input id="Button5" type="button" value="5"onclick="return Button_click('5')" /></td> <td class="style1"><input id="Button6" type="button" value="6"onclick="return Button_click('6')" /></td> <td class="style1"><input id="Button*" type="button" value="*"onclick="return Button_click('*')" /></td> <td class="style1"><input id="Button/" type="button" value="/"onclick="return Button_click('/')" /></td> </tr> <tr> <td class="style1"><input id="Button7" type="button" value="7"onclick="return Button_click('7')" /></td> <td class="style1"><input id="Button8" type="button" value="8" onclick="return Button_click('8')" /></td> <td class="style1"><input id="Button9" type="button" value="9" onclick="return Button_click('9')" /></td> <td rowspan=2 class="style1"><input id="Buttonjia" type="button" value="+" onclick="return Button_click('+')"/></td> <td class="style1"><input id="Button-" type="button" value="-" onclick="return Button_click('-')" /></td> </tr> <tr> <td class="style1"><input id="reset01" type="reset" value="重置"onclick="return Removeall()" /></td> <td class="style1"><input id="Button00" type="button" value="0"onclick="return Button_click('0')" /></td> <td class="style1"><input id="Button." type="button" value="." onclick="return Button_click('.')" /></td> <td class="style1"><input id="Button=" type="button" value="=" onclick="return Calculate('=')" /> </td> </tr> </table> </form> </div>

 

个人博客源地址:http://qtbk.xyz/?p=151

 

转载请注明原文地址: https://www.6miu.com/read-59691.html

最新回复(0)