<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      對于#include的補充說明

      [摘要]許多朋友都在問是否能動態的使用include?這在精華區中已經都有許多的篇幅說明了(關鍵字:include),在這里我再強調一下,<!--#include file="<%fileName%>"-->是絕對行不通的,要是使用<%if xxx = &...
      許多朋友都在問是否能動態的使用include?這在精華區中已經都有許多的篇幅說明了(關鍵字:include),在這里我再強調一下,<!--#include file="<%fileName%>"-->是絕對行不通的,要是使用
      <%if xxx = "yyy" then%>
      <!--#include file="file1.asp"-->
      <%else%>
      <!--#include file="file2.asp"-->
      <%end if%>
      這無形中會下載沒有必要的檔案,影響載入網頁的速度。如何解決這個問題呢?在精華區中的
      1)http://www.dev-club.com/club/bbs/showEssence.asp?id=14354
      2)http://www.dev-club.com/club/bbs/showEssence.asp?id=5246&page=1
      都做得很好的說明,在這里我不想重復。這些方法有:

      1)
      If xxx = "yyy" Then
        Server.Execute("file1.asp")
      Else
        Server.Execute("file2.asp")
      End If

      2)
      If xxx = "yyy" Then
        Server.transfer("file1.asp")
      Else
        Server.transfer("file2.asp")
      End If

      3)
      if xxx = "yyy" then
      filespec = "file2.asp"
      else
      filespec = "file2.asp"
      end if
      filespec = server.mapPath(filespec)
      scr = "scripting.fileSystemObject"
      set fs = server.createobject(scr)
      set f = fs.openTextFile(filespec)
      content = f.readall
      set f = nothing
      set fs = nothing
      response.write(content)

      我要說明的就是,如果使用以上方法來實現include功能的時候,必須注意的地方。
      我們可以將<!--#include file="file.asp"-->中被包含的網頁file.asp看成是包含了file.asp的網頁的有機組成部分,只是將本來屬于該網頁的內容以另一個檔案形式保存罷了,可以這樣說他們本來就是一個網頁,所以,被包含的網頁file.asp繼承了包含了file.asp的網頁的所有的參數設定,包括Session 但是,其他的方法并非如此,在html語法部分可以和主網頁共享,asp部分卻是獨立的,特別的Session在一般情況下是不能從主網頁中傳遞到被包含的網頁file.asp來,這點很重要,使用時要注意。



      日韩精品一区二区三区高清