转换html代码子程序

2016-01-29 18:11 2 1 收藏

转换html代码子程序,转换html代码子程序

【 tulaoshi.com - ASP 】

  function htmlencode(str)
    on error resume next
    dim result
    dim l
    if isnull(str) then
       htmlencode=""
       exit function
    end if

    l=len(str)
    result=""
dim i
for i = 1 to l
    select case mid(str,i,1)
           case "<"
                result=result+"&lt;"
           case ""
                result=result+"&gt;"
           case chr(34)
                result=result+"&quot;"
           case "&"
                result=result+"&amp;"
           case chr(13)
                result=result+"<br"
           case chr(9)
                result=result+"&nbsp;&nbsp;&nbsp;&nbsp;"
           case chr(32)            
                'result=result+"&nbsp;"
                if i+1<=l and i-10 then
                   if 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                       
                      result=result+"&nbsp;"
                   else
                      result=result+" "
                   end if
                else
                   result=result+"&nbsp;"                     
                end if
           case else
                result=result+mid(str,i,1)
         end select
       next
  &nb

来源:https://www.tulaoshi.com/n/20160129/1504750.html

延伸阅读
将一些HTML替换掉 eg: strContent=strContent.Replace("&","&"); strContent=strContent.Replace("'","''"); strContent=strContent.Replace(" strContent=strContent.Replace(">",">"); strContent=strContent.Replace("chr(60)","<"); strContent=strContent.Replace("chr(37)",">"); strContent=strContent.Replace("\"",""")...
讲了变量,现在也要讲讲“函数”和“子程序”了。 像“sin( )”、“abs( )”这些都是函数都是内部函数,现在我们要来讲讲外部函数,外部函数和变量一样在使用之前也是要先申明。它们的结构如下图所示。   函数则会把“a+b-c”的值返回给函数名“Getnumber”,如果我们输入Getnumber(9,4,2),则会返回“9+4-2”即“11...
最近研究怎么样使用HOOK拦截其他应用程序的消息,于是就动手写了一个钩子程序来挂到最常用的通讯及时通讯工具MSN,虽然没有什么实际意义,但作为学习研究却能够帮助我们理解利用HOOK是怎么样将自己编写的DLL注入已经存在的程序空间中的。 我们需要做的是通过我们自己编写的应用程序去拦截别人写好的应用程序消息,实际上这是在两个进...
标签: ASP
  这个程序主要用了IE5.5的一个特性 您的浏览器必须是IE5.5或以上版本 <html <head <titleWord2Html</title <script language="javascript" function convert2html(){     html.value = word.innerHTML;     } </script </head <body <p请在这里贴入WORD...
标签: Web开发
HTML是 HyperText Tarkup Language的缩写,即超文本标记语言,是在WWW上建立超文本文件的语言,它通过标记和属性对一段文本的语言进行描述,它提供超文本连接,可以指向网络中另一台计算机的文件,HTML还支持在文本中镶入图象,声音,动画等不同格式的文件,HTML还具有强大的排版功能,利用HTML可以制作出任意版面的主页。 HTML有什么...

经验教程

626

收藏

62

精华推荐

完美替换html代码

完美替换html代码

许怡的海岬

html 到 pdf的转换

html 到 pdf的转换

元寳同学

HTML代码简介(2)

HTML代码简介(2)

小柔柔的故事

微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部