?
本文檔使用 PHP中文網(wǎng)手冊 發(fā)布
ASP Response 對象用于從服務器向用戶發(fā)送輸出的結(jié)果。
ASP Response 對象用于從服務器向用戶發(fā)送輸出的結(jié)果。它的集合、屬性和方法描述如下:
集合 | 描述 |
---|---|
Cookies | 設置 cookie 的值。如果 cookie 不存在,則創(chuàng)建 cookie ,并設置指定的值。 |
屬性 | 描述 |
---|---|
Buffer | 規(guī)定是否緩沖頁面的輸出。 |
CacheControl | 設置代理服務器是否可以緩存由 ASP 產(chǎn)生的輸出。 |
Charset | 將字符集的名稱追加到 Response 對象中的 content-type 報頭。 |
ContentType | 設置 Response 對象的 HTTP 內(nèi)容類型。 |
Expires | 設置頁面在失效前的瀏覽器緩存時間(分鐘)。 |
ExpiresAbsolute | 設置瀏覽器上頁面緩存失效的日期和時間。 |
IsClientConnected | 指示客戶端是否已從服務器斷開。 |
Pics | 向 response 報頭的 PICS 標簽追加值。 |
Status | 規(guī)定由服務器返回的狀態(tài)行的值。 |
方法 | 描述 |
---|---|
AddHeader | 向 HTTP 響應添加新的 HTTP 報頭和值。 |
AppendToLog | 向服務器日志條目的末端添加字符串。 |
BinaryWrite | 在沒有任何字符轉(zhuǎn)換的情況下直接向輸出寫數(shù)據(jù)。 |
Clear | 清除已緩沖的 HTML 輸出。 |
End | 停止處理腳本,并返回當前的結(jié)果。 |
Flush | 立即發(fā)送已緩沖的 HTML 輸出。 |
Redirect | 把用戶重定向到一個不同的 URL。 |
Write | 向輸出寫指定的字符串。 |
使用 ASP 寫文本
本例演示如何使用 ASP 來寫文本。
<!DOCTYPE?html> <html> <body> <% response.write("Hello?World!") %> </body> </html>
Hello?World!
在 ASP 中使用 HTML 標簽格式化文本
本例演示如何使用 ASP 將文本和 HTML 標簽結(jié)合起來。
<!DOCTYPE?html> <html> <body> <% response.write("<h2>You?can?use?HTML?tags?to?format?the?text!</h2>") %> <% response.write("<p?style='color:#0000ff'>This?text?is?styled?with?the?style?attribute!</p>") %> </body> </html>
This text is styled with the style attribute!
將用戶重定向至一個不同的 URL
本例演示如何將用戶重定向至一個不同的 URL。
<% if?Request.Form("select")<>""?then ???????Response.Redirect(Request.Form("select")) end?if %>??? <!DOCTYPE?html> <html> <body> <form?action="demo_redirect.asp"?method="post"> <input?type="radio"?name="select"? value="demo_server.asp"> Server?Example<br> <input?type="radio"?name="select"? value="demo_text.asp"> Text?Example<br><br> <input?type="submit"?value="Go!"> </form> </body> </html>
顯示隨機的鏈接
本例演示如何創(chuàng)建一個隨機的鏈接。
<!DOCTYPE?html> <html> <body> <% randomize() r=rnd() if?r>0.5?then ??response.write("<a?) else ??response.write("<a?) end?if %> <p> This?example?demonstrates?a?link,?each?time?you?load?the?page,?it?will?display? one?of?two?links:?jianzhan.cc!?OR?Refsnesdata.no!?There?is?a?50%?chance?for? each?of?them. </p> </body> </html>
控制緩沖區(qū)
本例演示如何控制緩沖區(qū)。
<% Response.Buffer=true %> <!DOCTYPE?html> <html> <body> <p> This?text?will?be?sent?to?your?browser?when?my?response?buffer?is?flushed. </p> <% Response.Flush %> </body> </html>
清空緩沖區(qū)
本例演示如何清空緩沖區(qū)。
<% Response.Buffer=true %> <!DOCTYPE?html> <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>
在處理過程中終止腳本并返回結(jié)果
本例演示如何在處理過程中終止腳本。
<!DOCTYPE?html> <html> <body> <p>I?am?writing?some?text.?This?text?will?never?be<br> <% Response.End %> finished!?It's?too?late?to?write?more!</p> </body> </html>
設置頁面在失效前在瀏覽器中緩存時間
本例演示如何規(guī)定頁面在失效前在瀏覽器中的緩存時間。
<%Response.Expires=-1%> <!DOCTYPE?html> <html> <body> <p>This?page?will?be?refreshed?with?each?access!</p> </body> </html>
設置頁面緩存在瀏覽器中的失效日期或時間
本例演示如何規(guī)定頁面緩存在瀏覽器中的失效時間日期或時間。
<%Response.Expires=-1%> <!DOCTYPE?html> <html> <body> <p>This?page?will?be?refreshed?with?each?access!</p> </body> </html>
檢查用戶是否仍然與服務器連接
本例演示如何檢查用戶是否已與服務器斷開。
<!DOCTYPE?html> <html> <body> <% If?Response.IsClientConnected=true?then Response.Write("The?user?is?still?connected!") else Response.Write("The?user?is?not?connected!") end?if %> </body> </html>
設置內(nèi)容類型
本例演示如何規(guī)定內(nèi)容的類型。
<% Response.ContentType="text/html" %> <!DOCTYPE?html> <html> <body> <p>This?is?some?text</p> </body> </html>
設置字符集名稱
本例演示如何規(guī)定字符集的名稱。
<% Response.Charset="ISO8859-1" %> <!DOCTYPE?html> <html> <body> <p>This?is?some?text</p> </body> </html>