注册 登录
编程论坛 JavaScript论坛

在ASP中response.write方法中可直接使javasctipt函数吗?请高手指教。

sylknb 发布于 2010-02-08 12:02, 1681 次点击
<!--#include file="conn.asp"-->
<%
    Response.Expires = -1
    Response.ExpiresAbsolute = Now() - 1
    Response.CacheControl = "no-cache"

    Set Rs = Server.CreateObject("ADODB.Recordset")        
    Sql = "Select top 1 * From [Chat] Order By ID Desc"
    Rs.Open Sql,conn,1,1
    If Not Rs.EOF And Not Rs.BOF Then            
        Response.Write(escape(Rs("ID")&"§"&Rs("Talk")&"№"&Rs("SendTime")))
   
   
    End If
    Rs.Close
    Set Rs = nothing
%>

escape()在vbscript没有这种东西,找来找去好象是javascript

按ASP引用javasctipt脚本必须用<script language="javascript">......</scritp>,哪上面的代码中为什么可直接使用escape()?我是初学者不懂javascript
12 回复
#2
foktime2010-02-08 14:00
和明显 Response.Write()和escape()都是在asp代码里面的
asp有escape()这个方法
#3
aspic2010-02-08 14:11
escape是asp的函数
#4
sylknb2010-02-08 14:34
asp有escape()这个方法?是指VBscript的还是javascriptr ?
在纯的<%    %>中是否可以同时使用VBscript函数(或方法)javascriptr 函数(内置函数)
#5
sylknb2010-02-08 15:21
aspic:
escape是asp的函数 属于VBscript的还是javascriptr ?一般认为是VBscript


我从网上找到“JavaScript escape() 函数”定义和用法
escape() 函数可对字符串进行编码,这样就可以在所有的计算机上读取该字符串。

语法
escape(string)
#6
aspic2010-02-08 16:16
你那段代码里面就是vbscript的
#7
sylknb2010-02-08 16:38
vbscript里面有escape函数?怎么查不到?
#8
aspic2010-02-08 17:14
你那个应该是自己写的escape()函数吧
#9
aspic2010-02-08 17:14
程序代码:
Function escape(str)
    dim i,s,c,a
    s=""
    For i=1 to Len(str)
        c=Mid(str,i,1)
        a=ASCW(c)
        If (a>=48 and a<=57) or (a>=65 and a<=90) or (a>=97 and a<=122) Then
            s = s & c
        ElseIf InStr("@*_+-./",c)>0 Then
            s = s & c
        ElseIf a>0 and a<16 Then
            s = s & "%0" & Hex(a)
        ElseIf a>=16 and a<256 Then
            s = s & "%" & Hex(a)
        Else
            s = s & "%u" & Hex(a)
        End If
    Next
    escape = s
End Function
#10
sylknb2010-02-08 17:59
绝对不是自定义的,找遍了书中就是这样,没有自定义函数。我再一次贴上代码
<!--#include file="conn.asp"-->
<%
    Response.Expires = -1
    Response.ExpiresAbsolute = Now() - 1
    Response.CacheControl = "no-cache"

    Set Rs = Server.CreateObject("ADODB.Recordset")        
    Sql = "Select top 1 * From [Chat] Order By ID Desc"
    Rs.Open Sql,conn,1,1
    If Not Rs.EOF And Not Rs.BOF Then            
        Response.Write(escape(Rs("ID")&"§"&Rs("Talk")&"№"&Rs("SendTime")))书中这样注介的"返回unicode编码形式“
   
   
    End If
    Rs.Close
    Set Rs = nothing
%>
#11
aspic2010-02-09 08:49
conn.asp这里面也没有?
#12
aspic2010-02-09 08:54
测试了下 确实是asp(vbscript)自带的函数(方法)
#13
aspic2010-02-09 09:01
程序代码:
<%
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.CacheControl = "no-cache"
Response.Charset = "UTF-8"

For i = 0 To 10
    Response.Write "escape:"&escape("吼吼"&i) & "------------->"
    Response.Write "unescape:"&unescape(escape("吼吼"&i))&"<br />"
Next
%>
结果如下
程序代码:
escape:%u935A%u714E%u60E30------------->unescape:吼吼0
escape:%u935A%u714E%u60E31------------->unescape:吼吼1
escape:%u935A%u714E%u60E32------------->unescape:吼吼2
escape:%u935A%u714E%u60E33------------->unescape:吼吼3
escape:%u935A%u714E%u60E34------------->unescape:吼吼4
escape:%u935A%u714E%u60E35------------->unescape:吼吼5
escape:%u935A%u714E%u60E36------------->unescape:吼吼6
escape:%u935A%u714E%u60E37------------->unescape:吼吼7
escape:%u935A%u714E%u60E38------------->unescape:吼吼8
escape:%u935A%u714E%u60E39------------->unescape:吼吼9
escape:%u935A%u714E%u60E310------------->unescape:吼吼10
1