网页计算器
一款基于JavaScript的网页超酷网页计算器,黑色风格很好看,可以计算的项目很多,直接复制代码就可以使用。
答案:<title>网页计算器</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function doit() {
form.input.value = eval(form.input.value)
}
function Cos() {
x = form.input.value
if (x == '') alert('Error: Input Required');
else form.input.value = Math.cos(x);
}
function Sin() {
x = form.input.value
if (x == '') alert('Error: Input Required');
else form.input.value = Math.sin(x);
}
function Ln() {
x = form.input.value
if (x == '') alert('Error: Input Required');
else form.input.value = Math.log(x);
}
function Root() {
x = form.input.value
if (x == '') alert('Error: Input Required');
else form.input.value = Math.sqrt(x);
}
function Tan() {
x = form.input.value
if (x == '') alert('Error: Input Required');
else form.input.value = Math.tan(x);
}
function Icos() {
x = form.input.value
if (x == '') alert('Error: Input Required');
else form.input.value = Math.acos(x);
}
function Isin() {
x = form.input.value
if (x == '') alert('Error: Input Required');
else form.input.value = Math.asin(x);
}
function Itan() {
x = form.input.value
if (x == '') alert('Error: Input Required');
else form.input.value = Math.atan(x);
}
function Round() {
x = form.input.value
if (x == '') alert('Error: Input Required');
else form.input.value = Math.round(x);
}
function Ran() {
x = form.input.value
form.input.value = Math.random(x);
}
function Neg () {
x = form.input.value
if (x == '') alert('Error: Input Required');
else x = parseFloat(x) * -1;
}
function del() {
x = form.input.value
x = (x.substring) - 1
}
// End -->
</script>
<body bgcolor="#ffffff" onLoad="document.form.input.focus()">
<div align="center">
<form name="form" method="post" action="javascript:doit()">
<table width="260" border="0" height="260" align="center" bordercolor="#000000" bgcolor="#000000">
<tr bgcolor="#000000">
<td colspan="7" height="2">
<div align="center"><b><font face="Arial, Helvetica, sans-serif" color="#FFFFFF">高级计算器</font></b></div>
</td>
</tr>
<tr bgcolor="#000000">
<td colspan="7" height="2">
<div align="center">
<input type="text" name="input" size="40">
</div>
</td>
</tr>
<tr bgcolor="#000000">
<td width="50" height="4">
<input type="button" name="one" value="1" onClick="form.input.value += '1'" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50" height="4">
<input type="button" name="two" value="2" onClick="form.input.value += '2'" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50" height="4">
<input type="button" name="three" value="3" onClick="form.input.value += '3'" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="20" height="4"> </td>
<td width="50" height="4">
<input type="button" name="clear" value="C" onClick="form.input.value = ''" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #9F0004; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50" height="4">
<input type="button" name="percent" value=" % " onClick="form.input.value = eval(form.input.value) / 100" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50" height="4">
<input type="button" name="(" value=" ( " onClick="form.input.value += '('" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px">
</td>
</tr>
<tr bgcolor="#000000">
<td width="50" height="2">
<input type="button" name="four" value="4" onClick="form.input.value += '4'" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50" height="2">
<input type="button" name="five" value="5" onClick="form.input.value += '5'" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px">
</td><!-- http://www.zzzyk.com -->
<td width="50" height="2">
<input type="button" name="six" value="6" onClick="form.input.value += '6'" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="20" height="2"> </td>
<td width="50" height="2">
<input type="button" name="times" value=" x " onClick="form.input.value += ' * '" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50" height="2">
<input type="button" name="div" value=" / " onClick="form.input.value += ' / '" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50" height="2">
<input type="button" name=")" value=" ) " onClick="form.input.value += ')'" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px">
</td>
</tr>
<tr bgcolor="#000000">
<td width="50" height="2">
<input type="button" name="seven" value="7" onClick="form.input.value += '7'" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50" height="2">
<input type="button" name="eight" value="8" onClick="form.input.value += '8'" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50" height="2">
<input type="button" name="nine" value="9" onClick="form.input.value += '9'" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #666666; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="20" height="2"> </td>
<td width="50" height="2">
<input type="button" name="plus" value=" + " onClick="form.input.value += ' + '" style="COLOR: #FFFFFF; BACKGROUND-COLOR: #000000; HEIGHT: 25 px; WIDTH: 40px">
</td>
<td width="50" height="2">
<input type="button" name="minus" value=" - " onClick="form.input.value += ' - '" style="COLOR: #FFFFFF; BAC
上一个:JavaScript生成随机整数
下一个:JavaScript版贪吃蛇游戏代码