Javascript网页计算器
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>网页计算器</title>
<style type="text/css">
#container
{
width: 432px;
margin: 0 auto;
text-align: center;
height: 324px;
}
div
{
text-align: left;
width: 400px;
}
input
{
height: 37px;
width: 93px;
margin-bottom: 10px;
background: #CA0;
font-size: 30px;
}
input#answer
{
height: 37px;
width: 381px;
color: #FFF;
font-size: 35px;
text-align: right;
background: #38B;
}
input#equ
{
height: 37px;
width: 190px;
}
input#rst
{
height: 37px;
width: 190px;
}
</style>
<script language="javascript" type="text/javascript">
// 错误处理
window.onerror = function killerr() {
return true;
}
// 计算所需的两个因数
var param1, param2;
// 计算结果
var answer;
// 运算符
var oprt;
// 因数标记
var flag;
// 计算参数分配函数
function doCalc(val) {
if (document.getElementById("answer").getAttribute("value") == "ERROR" && val != "CE") {
// 计算器出错时提示,并终止操作
alert("Please reset calculator");
return false;
}
switch (val) {
// 操作符
case "+":
case "-":
相关文档:
1、function vv()
{
if(event.button==2)
{
alert('防止服务器负担过大,右键功能被屏蔽!')
......
<!---------<html>
<head>
<style type="text/css">
.tabheader table {
border-collapse: collapse; /* for IE */
border-spacing: 0; /* for N6 */
}
.tabheader table tr td {mar ......
javascript单引号和双引号区别2009-08-27 10:13在一个网页中的按钮,写onclick事件的处理代码,不小心写成如下:
IE提示出错后,再漫不经心地改为:
结果还是出错。
这时,我就想不通了,虽然我知道最直接的解决方法是写成这样:
但为什么javascript中的转义字符\没有效果了呢 ......