当前位置: 首页 > 图文教程 > 网络编程 > ASP > 一些简单的ASP练习

ASP
TSYS 新闻列表JS调用下载
使用asp代码突破图片的防盗连
一种理论上最快的Web数据库分页方法
asp:debug类调试程序
如何增加Referer功能--反向链接插件
pjblog中清空引用的小程序
光碟工具 Alcohol 120% v1.9.6.4719 下载(附序列号注册码)
ASP实现头像图像随机变换
UTF-8 Unicode Ansi 汉字GB2321几种编码转换程序
[转]XMLHTTPRequest的属性和方法简介
ASP常用函数:getpy()
我用ASP写的m行n列的函数,动态输出创建TABLE行列
ASP常用函数:Delay()
ASP常用函数:Trace()
[转]ASP实现关键词获取(各搜索引擎,GB2312及UTF-8)
对象标记具有无效的 ''MSWC.MyInfo'' ProgID
ServerVariables集合检索预定的环境变量
HTTP_HOST 和 SERVER_NAME 的区别详解
[转]ASP常用函数:TimeZone
Eval 函数 | Execute 语句 | ExecuteGlobal 语句

一些简单的ASP练习


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 48 ::
收藏到网摘: n/a

1,练习使用request对象接受数据,并且综合运用些函数。
cnbruce.html
<form action="cnbruce.asp" method="post">
<input type="text" name="title"><br>
<textarea name="content" rows=10 cols=20></textarea><br>
<input type="submit">
</form>

cnbruce.asp
<%
function th(str)
str=replace(str,"妈的","MD")
str=replace(str,"靠","KAO")
th=str
end function
function encode(str)
str = replace(str, ">", ">")
str = replace(str, "<", "<")
str = Replace(str, CHR(32), " ")
str = Replace(str, CHR(13), "")
str = Replace(str, CHR(10) & CHR(10), "</P><P>")
str = Replace(str, CHR(10), "<BR>")
encode=str
end function
%>
<%title=request.form("title")
content=request.form("content")%>
文章标题:<%=th(title)%><hr>
文章内容:<%=encode(th(content))%>

th(str)为自定义函数,主要功能很简单:过滤字符。encode(str)也为自定义函数,主要功能是完整地显示被传递的信息。
CHR(10)表示换行,CHR(13)表示回车,CHR(32)表示空格。
附加功能:显示UBB代码。
即ubb.asp中含有ubb()函数。
增强的cnbruce.asp
<!--#include file="http://www.cnbruce.com/blog/ubb.asp"-->
<%
function th(str)
str=replace(str,"妈的","MD")
str=replace(str,"靠","KAO")
th=str
end function
%>
<script>
function runEx(cod1) {
cod=document.all(cod1)
var code=cod.value;
if (code!=""){
var newwin=window.open('','','');
newwin.opener = null
newwin.document.write(code);
newwin.document.close();
}
}
</script>
<%title=request.form("title")
content=request.form("content")%>
文章标题:<%=th(title)%><hr>
文章内容:<%=ubb(unhtml(th(content)))%>