ASPチュートリアル

ASPホーム

WPチュートリアル

Webページの紹介 WebPages Razor Webページのレイアウト Webページフォルダ WebPages Global Webページフォーム Webページオブジェクト Webページファイル Webページデータベース Webページヘルパー WebPages WebGrid Webページチャート Webページの電子メール Webページのセキュリティ Webページの公開 Webページの例 Webページクラス

ASP.NET Razor

かみそりのイントロ かみそりの構文 Razor C#変数 Razor C#ループ Razor C#ロジック RazorVB変数 かみそりVBループ RazorVBロジック

ASPクラシック

ASPイントロ ASP構文 ASP変数 ASP手順 ASP条件文 ASPループ ASPフォーム ASPCookie ASPセッション ASPアプリケーション ASP #include ASP Global.asa ASP AJAX ASPメール ASPの例

ASPリファレンス

ASPVB関数 ASPVBキーワード ASP応答 ASPリクエスト ASPアプリケーション ASPセッション ASPサーバー ASPエラー ASPファイルシステム ASP TextStream ASPドライブ ASPファイル ASPフォルダー ASP辞書 ASP AdRotator ASP BrowserCap ASPコンテンツリンク ASPコンテンツローテーター ASPクイック参照

ADOチュートリアル

ADOイントロ ADOコネクト ADOレコードセット ADOディスプレイ ADOクエリ ADOソート ADO追加 ADOアップデート ADO削除 ADO Demo ADOスピードアップ

ADOオブジェクト

ADOコマンド ADO接続 ADOエラー ADOフィールド ADOパラメータ ADOプロパティ ADOレコード ADOレコードセット ADOストリーム ADOデータ型

ASPブラウザ機能コンポーネント


ASPブラウザ機能コンポーネント

ASPブラウザ機能コンポーネントは、訪問者のブラウザのタイプ、機能、およびバージョン番号を決定するBrowserTypeオブジェクトを作成します。

ブラウザがサーバーに接続すると、ユーザーエージェントヘッダーもサーバーに送信されます。このヘッダーには、ブラウザに関する情報が含まれています。

BrowserTypeオブジェクトは、ヘッダーの情報を「Browscap.ini」というサーバー上のファイルの情報と比較します。

ヘッダーのブラウザタイプとバージョン番号、および「Browscap.ini」ファイルの情報が一致する場合は、BrowserTypeオブジェクトを使用して、一致するブラウザのプロパティを一覧表示できます。Browscap.iniファイルにブラウザの種類とバージョン番号が一致しない場合は、すべてのプロパティが「不明」に設定されます。

構文

<%
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:
  • ActiveXControls - Support ActiveX controls?
  • Backgroundsounds - Support background sounds?
  • Cdf - Support Channel Definition Format for Webcasting?
  • Tables - Support tables?
  • Cookies - Support cookies?
  • Frames - Support frames?
  • Javaapplets - Support Java applets?
  • Javascript - Supports JScript?
  • Vbscript - Supports VBScript?
  • Browser - Specifies the name of the browser
  • Beta - Is the browser beta software?
  • Platform - Specifies the platform that the browser runs on
  • Version - Specifies the version number of the browser
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