<!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>
<script>
window.οnlοad=function()
{
var a=document.getElementById('value1');
var b=document.getElementById('value2');
var bu1=document.getElementById('but1');
var bu2=document.getElementById('but2');
var bu3=document.getElementById('but3');
var bu4=document.getElementById('but4');
bu1.οnclick=function()
{
var s=parseInt(a.value)+parseInt(b.value);
if(isNaN(s))
{
alert('输入了非数字!');
}
alert(s);
}
bu2.οnclick=function()
{
var s=parseInt(a.value)-parseInt(b.value);
if(isNaN(s))
{
alert('输入了非数字!');
}
alert(s);
}
bu3.οnclick=function()
{
var s=parseInt(a.value)*parseInt(b.value);
if(isNaN(s))
{
alert('输入了非数字!');
}
alert(s);
}
bu4.οnclick=function()
{
var s=parseInt(a.value)/parseInt(b.value);
if(isNaN(s))
{
alert('输入了非数字!');
}
alert(s);
}
}
</script>
</head>
<body>
<input type="text" id="value1" />
<input type="text" id="value2" />
<input type="button" id="but1" value="+" />
<input type="button" id="but2" value="-"/>
<input type="button" id="but3" value="*" />
<input type="button" id="but4" value="/"/>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
window.οnlοad=function()
{
var a=document.getElementById('value1');
var b=document.getElementById('value2');
var bu1=document.getElementById('but1');
var bu2=document.getElementById('but2');
var bu3=document.getElementById('but3');
var bu4=document.getElementById('but4');
bu1.οnclick=function()
{
var s=parseInt(a.value)+parseInt(b.value);
if(isNaN(s))
{
alert('输入了非数字!');
}
alert(s);
}
bu2.οnclick=function()
{
var s=parseInt(a.value)-parseInt(b.value);
if(isNaN(s))
{
alert('输入了非数字!');
}
alert(s);
}
bu3.οnclick=function()
{
var s=parseInt(a.value)*parseInt(b.value);
if(isNaN(s))
{
alert('输入了非数字!');
}
alert(s);
}
bu4.οnclick=function()
{
var s=parseInt(a.value)/parseInt(b.value);
if(isNaN(s))
{
alert('输入了非数字!');
}
alert(s);
}
}
</script>
</head>
<body>
<input type="text" id="value1" />
<input type="text" id="value2" />
<input type="button" id="but1" value="+" />
<input type="button" id="but2" value="-"/>
<input type="button" id="but3" value="*" />
<input type="button" id="but4" value="/"/>
</body>
</html>