台灣最大程式設計社群網站
線上人數
630
 
會員總數:245403
討論主題:189190
歡迎您免費加入會員
討論區列表 >> 專欄文章 >> 依據來訪者國家顯示正確的語系網頁
[]  
[我要回覆]
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
依據來訪者國家顯示正確的語系網頁
價值 : 0 QP  點閱數:1062 回應數:0

樓主

站務人員 站長
門外漢
0 1580
542 9
發送站內信

捐贈 VP 給 站務人員
以下文字節錄自MSDN

The following example shows the home page of a multi-lingual site. The home page is saved in UTF-8 format so characters from all languages can be shown. The home page redirects the client to a page of their language by using the ServerVariable HTTP_ACCEPT_LANGUAGE to discern the language of the client.

--- Default.asp ---


<%@ CodePage=65001 Language="VBScript"%>

<%

' Default.asp

' This file is saved in UTF-8 format.

' The codepage of the system doesn't matter because

' you are setting @CodePage, Response.CodePage, and Response.Charset.

' Otherwise, the system codepage of the server would be the default.


Response.CodePage = 65001

Response.CharSet = "utf-8"


' Redirect to the correct home page based on the client language.

Select Case Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")


Case "en-us", "en", "fr", "fr-fr", "es", "es-es", "zh", "zh-cn", "zh-tw"

Response.Redirect Request.ServerVariables("HTTP_ACCEPT_LANGUAGE") & "Start.asp"


Case Else

%>

Welcome. Click <a href="enStart.asp">here</a> to go to the English Web site.<BR><BR>

Bienvenue. Cliquetez <a href="frStart.asp">ici</a> pour aller au Web site francais.<BR><BR>

Recepcion. Haga clic <a href="esStart.asp">aqui</a> para ir al Web site espanol.<BR><BR>

[Chinese characters with a link]<BR><BR>

[Chinese - Taiwan characters with a link]<BR><BR>

<%

End Select

%>

--- En-usStart.asp ---


<%@ Language="VBScript" %>

<% Response.Redirect "enStart.asp" %>

--- EnStart.asp ---

<%@ CodePage=1252 Language="VBScript"%>

<%

' enStart.asp

' This file is saved in ANSI format on US English system locale.

' The language of the system doesn't matter

' because you are setting @CodePage and Response.CodePage.

' Otherwise, the system codepage of the server would be the default.

Response.CodePage = 1252

Response.CharSet = "windows-1252"

Response.Write "<H1 align=center>News for Today</H1>"

%>
本篇文章發表於2002-02-26 00:00
別忘捐VP感謝幫助你的人 新手會員瞧一瞧
目前尚無任何回覆
   

回覆
如要回應,請先登入.