ASP Buffer 屬性

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 對象參考手冊