账号通
    

账号  

密码  

1435

查看

0

回复
主题:[求助]怎么将asp 代码改为js调用输出,高手们给指导一下 [收藏主题]  
fengya1999 当前离线

432

主题

1

广播

0

粉丝
添加关注
级别:四年级

用户积分:4604 分
登录次数:495 次
注册时间:2007/7/18
最后登录:2015/6/15
fengya1999 发表于:2011/3/10 23:29:51   | 显示全部帖子 查看该作者主题 楼主 

我要将下列代码,变成一个JS,然后再模板中调用   <script type="text/javascript" src="/JS/XXX.js"></script>  



这段代码应该怎么改写一下,麻烦高手们给指导一下,谢谢





<%

' Local file to store XML

' You must create a blank file named "local_365142.xml" in the same

' directory as this script. It MUST be writable by the web

' server. On unix you would CHMOD 666 the file. On Windows

' you will need to access your custom control panel to set

' the permissions or contact your hosting company.

  

Const ForReading = 1, ForWriting = 2

  

Dim LOCAL_XML_FILENAME, sourceFile, FSO

  

LOCAL_XML_FILENAME = server.MapPath("local_365142.xml")

sourceFile = "http://www.text-link-ads.com/xml.php?inventory_key=GMRLT48QJTXYB8HT7C3E&referer=" & Server.UrlEncode(Request.ServerVariables("HTTP_REFERER")) & "&user_agent=" & Server.UrlEncode(Request.ServerVariables("HTTP_USER_AGENT"))

Set FSO = server.createObject("Scripting.FileSystemObject")

  

' update local XML

Dim DateMod, MonthString, DayString, DateModFile, DateModLimit

  

DateMod = FSO.getFile(LOCAL_XML_FILENAME).DateLastModified

  

MonthString = Month(DateMod)

If (MonthString < 10) Then

        MonthString = "0" & MonthString

End If

  

DayString = Day(DateMod)

If (DayString < 10) Then

        DayString = "0" & DayString

End If

  

DateModFile = Year(DateMod) & "-" & MonthString & "-" & DayString & " " & Hour(DateMod) & ":" & Minute(DateMod) & ":" & Second(DateMod)

  

MonthString = Month(Date)

If (MonthString < 10) Then

        MonthString = "0" & MonthString

End If

  

DayString = Day(Date)

If (DayString < 10) Then

        DayString = "0" & DayString

End If

  

DateModLimit = Year(Date) & "-" & MonthString & "-" & DayString & " " & (Hour(Now)-1) & ":" & Minute(Now) & ":" & Second(Now)

  

Dim Contents, Result, xmlhttp, TextStream

  

' read local XML

Contents = ""

Set TextStream = FSO.OpenTextFile(LOCAL_XML_FILENAME, ForReading, False, -2)

Do While Not TextStream.AtEndOfStream

        Contents = Contents & TextStream.ReadLine

Loop

TextStream.Close

Set TextStream = nothing

  

If (DateModFile < DateModLimit Or FSO.getFile(LOCAL_XML_FILENAME).size < 20) Then

        ' fetch remote XML

        Set xmlhttp = CreateObject("Microsoft.XMLHTTP")

        xmlhttp.open "GET", sourceFile, False

        xmlhttp.send ""

        Result = xmlhttp.responseText

        If (Result <> "") Then

                Contents = Result

        End If

  

        ' write new XML to local file

        Set TextStream = FSO.OpenTextFile(LOCAL_XML_FILENAME, ForWriting, True)

        TextStream.Write Contents

        TextStream.Close

        Set TextStream = nothing

End If

  

' parse local XML

Dim source

Set source = Server.CreateObject("Microsoft.XMLDOM")

source.async = false

source.loadXML(Contents)

  

' Output links

Dim objLst, i, numLinks, objLink, objLinkChildren, linkNode, URL, Text, BeforeText, AfterText

  

Set objLst = source.getElementsByTagName("Link")

numLinks = objLst.length - 1

  

Dim outhtm

  

outhtm="<ul>"

For i = 0 To numLinks

        Set objLink = objLst.item(i)

        Set objLinkChildren = objLink.childNodes

        URL = ""

        Text = ""

        BeforeText = ""

        AfterText = ""

  

        For Each linkNode In objLinkChildren

                If linkNode.nodeName = "URL" Then

                        URL = linkNode.text

                End If

                If linkNode.nodeName = "Text" Then

                        Text = linkNode.text

                End If

                If linkNode.nodeName = "BeforeText" Then

                        BeforeText = linkNode.text

                End If

                If linkNode.nodeName = "AfterText" Then

                        AfterText = linkNode.text

                End If

        Next

  

        outhtm=outhtm&"<li>" & BeforeText & "<a href=""" & URL & """>" & Text & "</a>" & AfterText & "</li>"

Next

outhtm=outhtm&"</ul><script src=""/tla.asp""></script>"

  

savetofile "tla.htm",outhtm

  

  

'savetofile  *** Copyright &copy Amznz.com All Rights Reserved. ***

public sub savetofile(l1,l2)'地址,内容

        dim l3

        on error resume next

        set l3=server.createobject("ADODB.Stream")

      

        with l3

                .type=2

                .open

                .charset="UTF-8"

                .position=l3.Size

                .writetext=l2

                .savetofile server.mappath(l1),2

                .close

        end with

        set l3=nothing

        if err.number<>0 then

                err.clear

        end if

end sub

  

  

%>

 
  支持(0) | 反对(0) 回到顶部顶端 回到底部底部
<上一主题 | 下一主题 >
Powered By KesionCMS Version X1
厦门科汛软件有限公司 © 2006-2016 页面执行0.10938秒 powered by KesionCMS 9.0