做程序经常有html与asp的代码互换

王朝asp·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

有什么问题请到<a href='/bbs/forums.php?fid=21'>论坛</a>中发表<br>

<!--# 特效来源:http://www.webjx.com/js -->

<!-- 把如下代码加入<body>区域中 -->

<SCRIPT language=vbscript>

<!--

function autocr()

if checkbox.checked then

html.wrap="soft"

asp.wrap="soft"

else

html.wrap="off"

asp.wrap ="off"

end if

end function

function HtmlToAsp(str)

dim i,AspStr,tmp,st

AspStr=""

for i=1 to Len (str)

tmp=Mid(str,i,1)

select case tmp

case """"

if not st thentmp=""""""

case "<"

if Mid(str,i+1,1)="%" then

tmp="""&"

if mid(str,i+2,1)="=" then i=i+2 else i=i+1

st=true

end if

case "%"

if Mid(str,i+1,1)=">" then

tmp="&"""

st=false

i=i+1

end if

end select

AspStr=AspStr&tmp

next

HtmlToAsp="Response.Write """&AspStr&"""&VbCrLf"

end function

function AspToHtml(str)

dim i,HtmStr,tmp,itmp,st

str=Trim(str)

HtmStr=""

st=3

if strcomp(mid(str,1,14),"Response.Write",1)=0 then str=LTrim(mid(str,15))

for i=1 to Len(str)

tmp=Mid (str,i,1)

if tmp="""" then

if mid(str,i+1,1)="""" and st=1 then

tmp=""""

i=i+1

elseif mid(str,i+1,1)="&" and st=1 then

st=0

if mid(str,i+2,1)="""" then

tmp=""

st=1

i=i+2

elseif strcomp(mid(str,i+2,6),"VbCrLf",1)=0 then

if i+7=len(str) then tmp="" else tmp=VbCrLf

i=i+7

else

tmp="<%"

i=i+1

end if

elseif st=3 then

tmp=""

st=1

elseif i=len(str) and st=1 then

tmp=""

st=0

end if

elseif tmp="&" and mid(str,i+1,1)="""" and st=0 then

st=1

tmp="%>"

i=i+1

end if

HtmStr=HtmStr&tmp

next

AspToHtml=HtmStr

end function

function hta()

dim ahtm,aspstr,inum

if html.value>"" then

ahtm=Split (html.value ,vbCrLf,-1,0)

inum=UBound(ahtm)

for i=0 to inum

aspstr=aspstr&HtmlToAsp (ahtm(i))

if i<inum-1 then aspstr=aspstr&vbCrLf

next

asp.value =aspstr

end if

end function

function ath()

dim aasp,htmstr,inum

if asp.value>"" then

aasp=Split (asp.value ,vbCrLf,-1,0)

inum=UBound (aasp)

for i=0 to inum

htmstr=htmstr&AspToHtml (aasp(i))

if i<inum-1 then htmstr =htmstr &vbCrLf

next

html.value =htmstr

end if

end function

function selall(obj)

obj.select

end function

-->

</SCRIPT>

<TABLE id=AutoNumber1 style="BORDER-COLLAPSE: collapse" borderColor=#111111

cellSpacing=0 cellPadding=5 width="100%" border=0>

<TBODY>

<TR>

<TD width="100%" colSpan=3><TEXTAREA class=myinput onfocus=selall(html) name=html rows=10 wrap=off cols=102></TEXTAREA>

</TD></TR>

<TR>

<TD width="40%">

<P align=right><INPUT class=mybutton style="WIDTH: 150px; HEIGHT: 25px" onclick=hta type=button value=HTML转ASP name=toasp>

</P></TD>

<TD width="16%"> <INPUT onclick=autocr type=checkbox value=checkbox

name=checkbox> 自动换行</TD>

<TD width="44%"><INPUT class=mybutton style="WIDTH: 150px; HEIGHT: 25px" onclick=ath type=button value=ASP转HTML name=tohtml>

</TD></TR>

<TR>

<TD width="100%" colSpan=3><TEXTAREA class=myinput onfocus=selall(asp) name=asp rows=10 wrap=off cols=102></TEXTAREA>

</TD></TR>

<TR align=middle>

<TD width="100%" colSpan=3> </TD></TR></TBODY></TABLE>

[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航