ASP是用來創建動態交互式網頁并建立強大的web應用程序,但是很多小伙伴們在學習ASP的時候都不知道應該怎么入手,那么我們現在就去看看小編整理的ASP的簡單練習。
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)))%> |
以上就是關于ASP的簡單練習,希望對大家的學習有所幫助,也希望大家多多支持錯新技術頻道。
新聞熱點
疑難解答