网站计数器代码
- 提问者网友:练爱
- 2021-07-18 00:19
- 五星知识达人网友:舍身薄凉客
- 2021-07-18 01:41
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>邓丹的计算器</title>
<style type="text/css">
body
{
background-image:url(file:///E|/My%20Documents/dengdan/1.jpg);
}
.STYLE1 {
font-size: 18px;
font-weight: bold;
color: #6699FF;
font-family: "Courier New", Courier, monospace;
}
#Layer1 {
position:absolute;
width:153px;
height:175px;
z-index:1;
left: 725px;
top: 277px;
}
</style>
<script language="javascript">
var deng="",dan="";
function disp(dan)
{
deng=document.form1.text1.value+dan;
document.form1.text1.value=deng;
}
function qingling()
{
document.form1.text1.value="";
}
function guanbi()
{
close();
}
function tuige()
{
var str1=document.form1.text1.value;
str1=str1.substring(0,str1.length-1);
document.form1.text1.value=str1;
}
function dengyu()
{
var str1=document.form1.text1.value;
var result=eval(str1);
document.form1.text1.value=result;
}
function bocai()
{
var now=new Date();
var hour=now.getHours();
var fen=now.getMinutes();
var miao=now.getSeconds();
if(hour<10)
hour="0"+hour;
if(fen<10)
fen="0"+fen;
if(miao<10)
miao="0"+miao;
var time="今天日期→"+now.getYear()+"年"+(now.getMonth()+1)+"月"+now.getDate()+"日 时间→"+hour+":"+fen+":"+miao;
document.form1.text2.value=time;
var time1=setTimeout("bocai()",1000);
}
</script>
</head>
<body onLoad="bocai()">
<center>
<form name="form1">
<p> </p>
<table width="247" border="5">
<caption align="center">
<span class="STYLE1">试做计算器</span>
</caption>
<tr>
<td colspan="5">
<input name="text1" type="text" value="0" size="32" onFocus="qingling()" />
</td>
<td>
<input name="deng" type="button" value="计算" onClick="dengyu()"/>
</td>
</tr>
<tr>
<td width="37">
<input name="1" type="button" value=" 1 " onClick="disp(1)"/>
</td>
<td width="37">
<input name="2" type="button" value=" 2 " onClick="disp(2)"/>
</td>
<td width="37">
<input name="3" type="button" value=" 3 " onClick="disp(3)"/>
</td>
<td width="37">
<input name="0" type="button" value=" 0 " onClick="disp(0)"/>
</td>
<td width="44">
<input name="mis" type="button" value=" - " onClick="disp('-')"/>
</td>
<td width="15">
<input name="tui" type="button" value="退格" onClick="tuige()"/>
</td>
</tr>
<tr>
<td>
<input name="4" type="button" value=" 4 " onClick="disp(4)"/>
</td>
<td>
<input name="5" type="button" value=" 5 " onClick="disp(5)"/>
</td>
<td>
<input name="6" type="button" value=" 6 " onClick="disp(6)"/>
</td>
<td>
<input name="dian" type="button" value=" . " onClick="disp('.')">
</td>
<td>
<input name="mul" type="button" value=" * " onClick="disp('*')"/>
</td>
<td>
<input name="qing" type="button" value="清零" onMouseDown="qingling()"/>
</td>
</tr>
<tr>
<td>
<input name="7" type="button" value=" 7 " onClick="disp(7)"/>
</td>
<td>
<input name="8" type="button" value=" 8 " onClick="disp(8)"/>
</td>
<td>
<input name="9" type="button" value=" 9 " onClick="disp(9)"/>
</td>
<td>
<input name="add" type="button" value=" + " onClick="disp('+')"/>
</td>
<td>
<input name="div" type="button" value=" / " onClick="disp('/')"/>
</td>
<td>
<input name="close" type="button" value="关闭" onClick="guanbi()"/>
</td>
</tr>
<tr>
<td colspan="6">
<input name="text2" type="text" size="38">
</td>
</tr>
</table>
<!-- 下面的 div 标签连接 上面的 ID选择器样式#Layer 显示连接图片 -->
</form>
</center>
</body>
</html>
这个是简易计算器的源代码!
至于怎么运行的嘛!你也应该明白哈!
- 1楼网友:怙棘
- 2021-07-18 03:19
那我就用asp吧!
代码如下:
它是两个文件组成的,一个一定要是Global.asa,代码是:
<script language="vbscript" runat="server">
sub application_onstart()
if isempty(application("counter")) then
application.lock()
application("counter")=0
application.unlock()
end if
application.lock()
application("counter")=application("counter")+1
application.unlock()
end sub
</script>
另一个文件index.asp的代码是:
<html>
<body>
你是第<%response.write application("counter")%>位访问者
</body>
</html>
这样应该ok了,要是你学过asp,应该会吧!