ASP Buffer 屬性


Response 對象參考手冊 完整的 Response 對象參考手冊

Buffer 屬性可規定是否對輸出進行緩衝。通常情況下,ASP 腳本在伺服器端執行,每句的執行結果都會發送到客戶端的流覽器上顯示出來。當輸出設置緩存時,伺服器會阻止向流覽器的回應,直到所有的伺服器腳本均被處理,或者直到腳本調用了 Flush 或 End 方法。

注意:如果要設置此屬性,它應當位於 .asp 檔中的 <html> 標籤之前。

語法

response.Buffer[=flag]

參數 描述
flag 布爾值,規定是否緩衝頁面輸出。

False 指示不緩存,伺服器會一邊處理一邊發送輸出。IIS version 4.0 默認為 False,而 IIS version 5.0 及更高的版本默認為 True。

True 指示緩衝。伺服器不會發送輸出,直到頁面上的所有腳本被處理,或者直到 Flush 或 End 方法被調用。

實例

實例 1

在這個實例中,在迴圈結束前不會被流覽器發送輸出。如果 buffer 被設置為 False ,則每迴圈一次就向流覽器輸出一行。

<%response.Buffer=true%>
<html>
<body>
<%
for i=1 to 100
  response.write(i & "<br>")
next
%>
</body>
</html>

實例 2

<%response.Buffer=true%>
<html>
<body>
<p>I write some text, but I will control when
the text will be sent to the browser.</p>
<p>The text is not sent yet. I hold it back!</p>
<p>OK, let it go!</p>
<%response.Flush%>
</body>
</html>

實例 3

<%response.Buffer=true%>
<html>
<body>
<p>This is some text I want to send to the user.</p>
<p>No, I changed my mind. I want to clear the text.</p>
<%response.Clear%>
</body>
</html>


Response 對象參考手冊 完整的 Response 對象參考手冊