提交表单时如何做到实现简单的编辑?

我做一个学术网站,内容主要是文本的,偶尔一些文章会有一些图片以及超链接需要插入其中。我如何做到如中国人校友录的多彩文本留言那样,对要提交的表单实行添加超链接或图片的编辑功能呢?

请各位高手解说一下,并给出一个例子的源码,多谢!100分相赠。
---------------------------------------------------------------

那实际上是要对提交的内容进行编码的过程。循环读出内容,当有符合条件的词条时,添加HTML标记进内容里。

建议参考UBB的代码,我给你个我自己写的过滤HTML的ASP代码。你改改也可以实现。

 1   
 2function htmlencode2(str)   
 3dim result   
 4dim l   
 5if isNULL(str) then   
 6htmlencode2=""   
 7exit function   
 8end if   
 9l=len(str)   
10result=""   
11dim i   
12for i = 1 to l   
13select case mid(str,i,1)   
14case "<"   
15result=result+"<"   
16case ">"   
17result=result+">"   
18case chr(13)   
19result=result+"

<br/>

 1"   
 2case chr(34)   
 3result=result+"""   
 4case "&"   
 5result=result+"&"   
 6case chr(32)   
 7'result=result+" "   
 8if i+1<=l and i-1>0 then   
 9if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then   
10result=result+" "   
11else   
12result=result+" "   
13end if   
14else   
15result=result+" "   
16end if   
17case chr(9)   
18result=result+" "   
19case "'"   
20result=result+"´"   
21case else   
22result=result+mid(str,i,1)   
23end select   
24next   
25htmlencode2=result   
26end function   
Published At
Categories with Web编程
Tagged with
comments powered by Disqus