•   ÄúµÄλÖÃ:֪ʶ¿âÊ×Ò³ >> µçÄÔ֪ʶ >> ÍøÕ¾½¨Éè >> ASP
  • ASPÉú³É¾²Ì¬HtmlÎļþ¼¼ÊõÔÓ̸

    ·¢²¼Ê±¼ä:2007-3-12  ÔðÈα༭:omega  ä¯ÀÀ´ÎÊý:
    ÍøÒ³Éú³É¾²Ì¬HtmlÎļþÓÐÐí¶àºÃ´¦,±ÈÈçÉú³ÉhtmlÍøÒ³ÓÐÀûÓÚ±»ËÑË÷ÒýÇæÊÕ¼,²»½ö±»ÊÕ¼µÄ¿ì»¹ÊÕ¼µÄÈ«.ǰ̨ÍÑÀëÁËÊý¾Ý·ÃÎÊ,¼õÇá¶ÔÊý¾Ý¿â·ÃÎʵÄѹÁ¦,¼Ó¿ìÍøÒ³´ò¿ªËÙ¶È.
    Ïñwww.yangchun.orgµÄÖ÷Õ¾¾Í²ÉÓÃÁËÉú³ÉhtmlÎļþµÄ·½·¨!


    1,ÏÂÃæÕâ¸öÀý×ÓÖ±½ÓÀûÓÃFSO°Ñhtml´úÂëдÈëµ½ÎļþÖÐÈ»ºóÉú³É.html¸ñʽµÄÎļþ <%
    filename="test.htm"
    if request("body")<>"" then
    set fso = Server.CreateObject("Scripting.FileSystemObject")
    set htmlwrite = fso.CreateTextFile(server.mappath(""&filename&""))
    htmlwrite.write "<html><head><title>" & request.form("title") & "</title></head>"
    htmlwrite.write "<body>Êä³öTitleÄÚÈÝ: " & request.form("title") & "<br /> Êä³öBodyÄÚÈÝ:" & request.form("body")& "</body></html>"
    htmlwrite.close
    set fout=nothing
    set fso=nothing
    end if
    %>
    <form name="form" method="post" action="">
    <input name="title" value="Title" size=26>
    <br>
     <textarea name="body">Body</textarea>
     <br>
     <br>
     <input type="submit" name="Submit" value="Éú³Éhtml">
    </form>
    2,µ«Êǰ´ÕÕÉÏÃæµÄ·½·¨Éú³ÉhtmlÎļþ·Ç³£²»·½±ã,µÚ¶þÖÖ·½·¨¾ÍÊÇÀûÓÃÄ£°å¼¼Êõ,½«Ä£°åÖÐÌØÊâ´úÂëµÄÖµÌæ»»Îª´Ó±íµ¥»òÊÇÊý¾Ý¿â×Ö¶ÎÖнÓÊܹýÀ´µÄÖµ,Íê³ÉÄ£°å¹¦ÄÜ;½«×îÖÕÌæ»»¹ýµÄËùÓÐÄ£°å´úÂëÉú³ÉHTMLÎļþ.ÕâÖÖ¼¼Êõ²ÉÓõñȽ϶à,´ó²¿·ÖµÄCMS¶¼ÊÇʹÓÃÕâÀà·½·¨.
    template.htm ' //Ä£°åÎļþ <html>
    <head>
    <title>$title$ by aspid.cn</title>
    </head>
    <body>
    $body$
    </body>
    </html>ÿ

    TestTemplate.asp '// Éú³ÉHtml <%
    Dim fso,htmlwrite
    Dim strTitle,strContent,strOut
    '// ´´½¨Îļþϵͳ¶ÔÏó
    Set fso=Server.CreateObject("Scripting.FileSystemObject")
    '// ´ò¿ªÍøÒ³Ä£°åÎļþ£¬¶Áȡģ°åÄÚÈÝ
    Set htmlwrite=fso.OpenTextFile(Server.MapPath("Template.htm"))
    strOut=f.ReadAll
    htmlwrite.close

    strTitle="Éú³ÉµÄÍøÒ³±êÌâ"
    strContent="Éú³ÉµÄÍøÒ³ÄÚÈÝ"

    '// ÓÃÕæÊµÄÚÈÝÌæ»»Ä£°åÖеıê¼Ç
    strOut=Replace(strOut,"$title$",strTitle)
    strOut=Replace(strOut,"$body$",strContent)

    '// ´´½¨ÒªÉú³ÉµÄ¾²Ì¬Ò³
    Set htmlwrite=fso.CreateTextFile(Server.MapPath("test.htm"),true)

    '// дÈëÍøÒ³ÄÚÈÝ
    htmlwrite.WriteLine strOut
    htmlwrite.close

    Response.Write "Éú³É¾²Ì¬Ò³³É¹¦£¡"

    '// ÊÍ·ÅÎļþϵͳ¶ÔÏó
    set htmlwrite=Nothing
    set fso=Nothing
    %>

    3,µÚÈýÖÖ·½·¨¾ÍÊÇÓÃXMLHTTP»ñÈ¡¶¯Ì¬Ò³Éú³ÉµÄHTMLÄÚÈÝ£¬ÔÙÓÃADODB.Stream»òÕßScripting.FileSystemObject±£´æ³ÉhtmlÎļþ¡£Õâ¾ä»°ÊÇÔÚÀ¶É«ÀíÏëÉÏ¿´µ½µÄ,¶ÔXMLHTTPÒ÷Ç廹²»ÊìϤÕýÔÚÕÒ×ÊÁÏÁ˽â.ÕÒµ½Ò»¶ÎXMLHTTPÉú³ÉHtmlµÄ´úÂë²Î¿¼Ò»ÏÂ.
    <%

    '³£Óú¯Êý
    '1¡¢ÊäÈëurlÄ¿±êÍøÒ³µØÖ·£¬·µ»ØÖµgetHTTPPageÊÇÄ¿±êÍøÒ³µÄhtml´úÂë
    function getHTTPPage(url)
    dim Http
    set Http=server.createobject("MSXML2.XMLHTTP")
    Http.open "GET",url,false
    Http.send()
    if Http.readystate<>4 then
    exit function
    end if
    getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
    set http=nothing
    if err.number<>0 then err.Clear
    end function

    '2¡¢×ª»»ÂÒÂֱ꣬½ÓÓÃxmlhttpµ÷ÓÃÓÐÖÐÎÄ×Ö·ûµÄÍøÒ³µÃµ½µÄ½«ÊÇÂÒÂ꣬¿ÉÒÔͨ¹ýadodb.stream×é¼þ½øÐÐת»»
    Function BytesToBstr(body,Cset)
    dim objstream
    set objstream = Server.CreateObject("adodb.stream")
    objstream.Type = 1
    objstream.Mode =3
    objstream.Open
    objstream.Write body
    objstream.Position = 0
    objstream.Type = 2
    objstream.Charset = Cset
    BytesToBstr = objstream.ReadText
    objstream.Close
    set objstream = nothing
    End Function
     

    txtURL=server.MapPath("../index.asp")

    sText = getHTTPPage(txtURL)

    Set FileObject=Server.CreateObject("Scripting.FileSystemObject")
    filename="../index.htm"
    Set openFile=FileObject.OpenTextfile(server.mapPath(filename),2,true) 'trueΪ²»´æÔÚ×ÔÐн¨Á¢
    openFile.writeline(sText)
    Set OpenFile=nothing

    %>
    <script>
    alert("¾²Ì¬ÍøÒ³Éú³ÉÍê±Ï");
    history.back();
    </script>

    ¡¾ÉùÃ÷¡¿£º
    ¡¡¡¡ÒÔÉÏÎÄÕ»ò×ÊÁϳý×¢Ã÷ΪYangChun.org×Ô´´»ò±à¼­ÕûÀíÍ⣬¾ùΪ¸÷·½ÊÕ¼¯»òÍøÓÑÍÆ¼öËùµÃ¡£ÆäÖÐժ¼µÄÄÚÈÝÒÔ¹²Ïí¡¢Ñо¿ÎªÄ¿µÄ£¬²»´æÔÚÈκÎÉÌÒµ¿¼ÂÇ¡£
    ¡¡¡¡Ä¿Ç°ÍøÕ¾ÉÏÓÐЩÎÄÕÂδעÃ÷×÷Õß»ò³ö´¦£¬ÉõÖÁ±ê×¢´íÎ󣬴ËÀàÇé¿ö³öÏÖ²¢·Ç²»×ðÖØ×÷Õß¼°³ö´¦ÍøÕ¾£¬¶øÊÇÒòΪÓÐЩ×ÊÁÏÀ´Ô´µÄ²»¹æ·¶¡£Èç¹ûÓÐÁ˽â×÷Õß»ò³ö´¦µÄÔ­×÷Õß»òÍøÓÑ£¬Çë¸æÖª£¬±¾ÍøÕ¾½«Á¢¼´¸üÕý×¢Ã÷£¬²¢Ïò×÷Õß»ò³ö´¦µ¥Î»µÀǸ¡£
    ¡¡¡¡±»ÕªÂ¼µÄ¶ÔÏóÈçÓÐÈκÎÒìÒ飬ÇëÓë±¾Õ¾ÁªÏµ£¬ÁªÏµÓÊÏ䣺WebMaster#YangChun.org£¬±¾Õ¾È·ÈϺó½«Á¢¼´³·Ï¡£Ð»Ð»ÄúµÄÖ§³ÖÓëÀí½â£¡
    ÔÞÖúÉÌ



    Google
     
    Ñô´ºÈÈÏß-֪ʶ¿â
    ±¾Õ¾Ö£ÖØÉùÃ÷£ºËùÔØÎÄÕ¡¢Êý¾Ý½ö¹©²Î¿¼£¬Ê¹ÓÃǰÎñÇëºËʵ£¬·çÏÕ×Ô¸º¡£
    Copyright © 2004-2007  YangChun.org  ±¸°¸ÐòºÅ:ÔÁICP±¸05075203  Ñô´ºÍ¬Ïç»áÖ÷°ì