菜单

TS判断系统与浏览器

2010年08月30日 - typoscript

General notes:

Values are normally trimmed for whitespaces before comparison.

You may combine several conditions with two operators: && (and), || (or)

Alternatively you may use “AND” and “OR” instead of “&&” and “||”. The AND operator has always higher precedence over OR. If no operator has been specified, it will default to OR.

Examples:

This condition will match if the visitor opens the website with Internet Explorer on Windows (but not on Mac)

[browser = msie] && [system = win]

This will match with either Opera or Netscape browsers

[browser = opera] || [browser = netscape]

This will match with either Internet Explorer or Netscape. In case of Netscape, the version must be above 4.

[browser = msie] || [browser = netscape] && [version => 4]

browser

Syntax:

[browser = browser1,browser2,...]

Values and comparison:

Browser: Identification:
Microsoft Internet Explorer msie
Netscape Communicator netscape
Lynx lynx
Opera opera
PHP fopen php
AvantGo (www.avantgo.com) avantgo
Adobe Acrobat WebCapture acrobat
IBrowse (amiga-browser) ibrowse
Teleport Pro teleport
?? (if “mozilla” is not in useragent) unknown

Each value is compared with the ($browsername.$browserversion, eg. “netscape4.72”) in a strstr().

So if the value is “netscape” or just “scape” or “net” all netscape browsers will match.

If the value is “netscape4” all netscape 4.xx browsers will match.

If any value in the list matches the current browser, the condition returns true.

Examples:

This will match with netscape and opera-browsers

[browser = netscape, opera]

version

Syntax:

[version = value1, >value2, =value3, <value4, ...]

Comparison:

values are floating-point numbers with “.” as the decimal separator.

The values may be preceeded by three operators:

Operator: Function:
[nothing] The value must be part of the beginning of the version as a string. This means that if the version is “4.72” and the value is “4” or “4.7” it matches. But “4.73” does not match.

Example from syntax: “value1”

= The value must match exactly. Version “4.72” matches only with a value of “4.72”
> The version must be greather than the value
< The version must be less than the value
Examples:

This matches with exactly “4.03” browsers

[version=  =4.03]

This matches with all 4+ browsers and netscape 3 browsers

[version=  >4][browser= netscape3]

system

Syntax:

[system= system1,system2]

Values and comparison:

System: Identification:
Linux linux
SGI / IRIX unix_sgi
SunOS unix_sun
HP-UX unix_hp
Macintosh mac
Windows 3.11 win311
Windows NT winNT
Windows 95 win95
Windows 98 win98
Amiga amiga

Values are strings an a match happens if one of these strings is the first part of the system-identification.

Fx. if the value is “win9” this will match with “win95” and “win98” systems.

Examples:

This will match with windows and mac -systems only

[system= win,mac]

device

Syntax:

[device= device1, device2]

Values and comparison:

Device: Identification:
HandHeld pda
WAP phones wap
Grabbers: grabber
Indexing robots: robot

Values are strings an a match happens if one of these strings equals the type of device

Examples:

This will match WAP-phones and PDA’s

[device= wap, pda]

useragent

Syntax:

[useragent= agent]

Values and comparison:

This is a direct match on the useragent string from getenv(“HTTP_USER_AGENT”)

You have the options of putting a “*” at the beginning and/or end of the value agent thereby matching with this wildcard!

Examples:

If the HTTP_USER_AGENT is “Mozilla/4.0 (compatible; Lotus-Notes/5.0; Windows-NT)” this will match with it:

[useragent = Mozilla/4.0 (compatible; Lotus-Notes/5.0; Windows-NT)]

This will also match with it:

[useragent = *Lotus-Notes*]

… but this will also match with a useragent like this: “Lotus-Notes/4.5 ( Windows-NT )”

A short list of user-agent strings and a proper match:

HTTP_USER_AGENT: Agent description: Matching condition:
Nokia7110/1.0+(04.77) Nokia 7110 WAP phone [useragent= Nokia7110*]
Lotus-Notes/4.5 ( Windows-NT ) Lotus-Notes browser [useragent= Lotus-Notes*]
Mozilla/3.0 (compatible; AvantGo 3.2) AvantGo browser [useragent= *AvantGo*]
Mozilla/3.0 (compatible; WebCapture 1.0; Auto; Windows) Adobe Acrobat 4.0 [useragent= *WebCapture*]

WAP-agents:

This is some of the known WAP agents:

HTTP_USER_AGENT HTTP_USER_AGENT (continued)
ALAV UP/4.0.7

Alcatel-BE3/1.0 UP/4.0.6c

AUR PALM WAPPER

Device V1.12

EricssonR320/R1A

fetchpage.cgi/0.53

Java1.1.8

Java1.2.2

m-crawler/1.0 WAP

Materna-WAPPreview/1.1.3

MC218 2.0 WAP1.1

Mitsu/1.1.A

MOT-CB/0.0.19 UP/4.0.5j

MOT-CB/0.0.21 UP/4.0.5m

Nokia-WAP-Toolkit/1.2

Nokia-WAP-Toolkit/1.3beta

Nokia7110/1.0 ()

Nokia7110/1.0 (04.67)

Nokia7110/1.0 (04.67)

Nokia7110/1.0 (04.69)

Nokia7110/1.0 (04.70)

Nokia7110/1.0 (04.71)

Nokia7110/1.0 (04.73)

Nokia7110/1.0 (04.74)

Nokia7110/1.0 (04.76)

Nokia7110/1.0 (04.77)

Nokia7110/1.0 (04.80)

Nokia7110/1.0 (30.05)

Nokia7110/1.0

PLM’s WapBrowser

QWAPPER/1.0

R380 2.0 WAP1.1

SIE-IC35/1.0

SIE-P35/1.0 UP/4.1.2a

SIE-P35/1.0 UP/4.1.2a

UP.Browser/3.01-IG01

UP.Browser/3.01-QC31

UP.Browser/3.02-MC01

UP.Browser/3.02-SY01

UP.Browser/3.1-UPG1

UP.Browser/4.1.2a-XXXX

UPG1 UP/4.0.7

Wapalizer/1.0

Wapalizer/1.1

WapIDE-SDK/2.0; (R320s (Arial))

WAPJAG Virtual WAP

WAPJAG Virtual WAP

WAPman Version 1.1 beta:Build W2000020401

WAPman Version 1.1

Waptor 1.0

WapView 0.00

WapView 0.20371

WapView 0.28

WapView 0.37

WapView 0.46

WapView 0.47

WinWAP 2.2 WML 1.1

wmlb

YourWap/0.91

YourWap/1.16

Zetor

发表评论

电子邮件地址不会被公开。 必填项已用*标注