ASP 브라우저 기능 구성 요소
ASP 브라우저 기능 구성 요소
ASP 브라우저 기능 구성 요소는 방문자 브라우저의 유형, 기능 및 버전 번호를 결정하는 BrowserType 개체를 만듭니다.
브라우저가 서버에 연결되면 사용자 에이전트 헤더도 서버로 전송됩니다. 이 헤더에는 브라우저에 대한 정보가 포함되어 있습니다.
BrowserType 개체는 헤더의 정보를 "Browscap.ini"라는 서버의 파일에 있는 정보와 비교합니다.
헤더의 브라우저 유형 및 버전 번호와 "Browscap.ini" 파일의 정보가 일치하는 경우 BrowserType 개체를 사용하여 일치하는 브라우저의 속성을 나열할 수 있습니다. Browscap.ini 파일에 브라우저 유형 및 버전 번호가 일치하지 않으면 모든 속성이 "UNKNOWN"으로 설정됩니다.
통사론
<%
Set MyBrow=Server.CreateObject("MSWC.BrowserType")
%>
ASP 브라우저 기능 예
아래 예는 ASP 파일에 BrowserType 개체를 만들고 브라우저의 일부 기능을 표시합니다.
예시
<!DOCTYPE html>
<html>
<body>
<%
Set MyBrow=Server.CreateObject("MSWC.BrowserType")
%>
<table border="0" width="100%">
<tr>
<th>Client OS</th><th><%=MyBrow.platform%></th>
</tr><tr>
<td >Web Browser</td><td ><%=MyBrow.browser%></td>
</tr><tr>
<td>Browser version</td><td><%=MyBrow.version%></td>
</tr><tr>
<td>Frame support?</td><td><%=MyBrow.frames%></td>
</tr><tr>
<td>Table support?</td><td><%=MyBrow.tables%></td>
</tr><tr>
<td>Sound support?</td><td><%=MyBrow.backgroundsounds%></td>
</tr><tr>
<td>Cookies support?</td><td><%=MyBrow.cookies%></td>
</tr><tr>
<td>VBScript support?</td><td><%=MyBrow.vbscript%></td>
</tr><tr>
<td>JavaScript support?</td><td><%=MyBrow.javascript%></td>
</tr>
</table>
</body>
</html>
산출:
Client OS | WinNT |
---|---|
Web Browser | IE |
Browser version | 5.0 |
Frame support? | True |
Table support? | True |
Sound support? | True |
Cookies support? | True |
VBScript support? | True |
JavaScript support? | True |
Browscap.ini 파일
"Browscap.ini" 파일은 속성을 선언하고 브라우저의 기본값을 설정하는 데 사용됩니다.
이 섹션은 "Browscap.ini" 파일을 유지 관리하는 방법에 대한 자습서가 아니며 기본 사항만 보여줍니다. 파일이 무엇인지 알 수 있습니다.
"Browscap.ini" 파일에는 다음이 포함될 수 있습니다.
[;comments]
[HTTPUserAgentHeader]
[parent=browserDefinition]
[property1=value1]
[propertyN=valueN]
[Default Browser Capability Settings]
[defaultProperty1=defaultValue1]
[defaultPropertyN=defaultValueN]
Parameter | Description |
---|---|
comments | Optional. Any line that starts with a semicolon are ignored by the BrowserType object |
HTTPUserAgentHeader | Optional. Specifies the HTTP User Agent header to associate with the browser-property value statements specified in propertyN. Wildcard characters are allowed |
browserDefinition | Optional. Specifies the HTTP User Agent header-string of a browser to use as the parent browser. The current browser's definition will inherit all of the property values declared in the parent browser's definition |
propertyN | Optional. Specifies the browser properties. The following table lists some possible properties:
|
valueN | Optional. Specifies the value of propertyN. Can be a string, an integer (prefix with #), or a Boolean value |
defaultPropertyN | Optional. Specifies the name of the browser property to which to assign a default value if none of the defined HTTPUserAgentHeader values match the HTTP User Agent header sent by the browser |
defaultValueN | Optional. Specifies the value of defaultPropertyN. Can be a string, an integer (prefix with #), or a Boolean value |
"Browscap.ini" 파일은 다음과 같습니다.
;IE 5.0
[IE 5.0]
browser=IE
Version=5.0
majorver=#5
minorver=#0
frames=TRUE
tables=TRUE
cookies=TRUE
backgroundsounds=TRUE
vbscript=TRUE
javascript=TRUE
javaapplets=TRUE
ActiveXControls=TRUE
beta=False
;DEFAULT BROWSER
[*]
browser=Default
frames=FALSE
tables=TRUE
cookies=FALSE
backgroundsounds=FALSE
vbscript=FALSE
javascript=FALSE