日期:2014-05-17  浏览次数:20853 次

判断粘贴内容中是否有限制代码


用在线编辑器ewebeditor编辑方式时,需要限制通过复制粘贴的方式把例如   script   frame   include   select   update   delete   等插入到编辑框中来.

如何能够在保证粘贴功能的情况下去掉以上限制代码?   例如以其他代码代替.如 <br   代替   <script   .
或者发现有以上代码粘贴就提示并阻止也可以.
最好能够将以上代码的字符构造也一起判断并阻止.

------解决方案--------------------
str=Trim(Request( "str "))
errorchar=array( "% ", "# ", "& ", " < ", "> ", " <br> ", "iframe ", "SCRIPT ", "TEXTAREA ", "onmouseover ", "insert ", "select ", "update ", "count ", "delete ", "where ", "exec ", "chr ", "mid ", "master ", "truncate ", "char ", "declare ", "split ")
for i=0 to ubound(errorchar)
if instr(str,errorchar(i))> 0 then j=100
next

if j=100 then
response.write " <script language= 'javascript '> "
response.write "alert( '请不要在使用非法字符…… '); "
response.write "location.href= 'javascript:history.go(-1) '; "
response.write " </script> "
response.end
end if
想限制什么自己写上