Determine Web browser, version, and platform from an HTTP user agent string
Description
This plugin leverages
HTTP::BrowserDetect for wiki apps. In general your wiki apps should
not depend on
a specific browser. However it might be useful to distiguish the
device the wiki app is running on such as tablets vs desktop vs mobile ones.
Usage
%BROWSERINFO{"<format-string>" ua="..."}%
By default the properties of the current browser are extracted. However you might use the
ua="..."
string to test different devices.
The
<format-string>
might contain a variety of variables that are expanded to the properties found in the current device.
Context
Boolean browser properties - those that return 1 or 0 are flagged to the Foswiki context as well so that you can make use of them in
System.IfStatements. Below example will generate two different whatsapp links depending on whether you are on a mobile
device or not.
You type:
<a href="%IF{"context mobile"
then="whatsapp://"
else="https://web.whatsapp.com?"
}%send?text=%ENCODE{"Hello World"}%">
%JQICON{"fa-whatsapp"}% Share on !WhatsApp
</a>
You get:
Share on WhatsApp
Context settings are:
gecko webkit trident presto khtml edgehtml
windows win16 win3x win31 win32 winme win95 win98 winnt win2k winxp win2k3
winvista win7 win8 win8_0 win8_1 win10 win10_0 wince winphone winphone7
winphone7_5 winphone8 winphone10
adm android aol aol3 aol4 aol5 aol6 applecoremedia audrey avantgo avantgo
blackberry browsex chrome dalvik dsi elinks emacs epiphany firefox galeon icab
ie ie10 ie11 ie3 ie4 ie4up ie5 ie55 ie55up ie5up ie6 ie7 ie8 ie9 ie_compat_mode
edge edgelegacy
iopener ipad iphone ipod kindle kindlefire konqueror links lotusnotes lynx
mobile_safari mosaic mozilla n3ds nav2 nav3 nav4 nav45 nav45up nav4up nav6
nav6up navgold neoplanet neoplanet2 netfront netscape obigo
opera opera3 opera4 opera5 opera6 opera7
palm polaris ps3 psp pubsub realplayer realplayer_browser safari seamonkey silk
staroffice ucbrowser wap webos webtv
mac mac68k macppc macosx ios
unix sun sun4 sun5 suni86 irix irix5 irix6 hpux hpux9 hpux10 aix aix1 aix2 aix3
aix4 linux sco unixware mpras reliant dec sinix freebsd bsd
chromeos dotnet firefoxos lib mobile robot tablet webview x11
vms amiga ps3gameos pspgameos
General Properties
Property |
Value |
browser |
%BROWSERINFO{"$browser"}% |
browser_string |
%BROWSERINFO{"$browser_string"}% |
browser_version |
%BROWSERINFO{"$browser_version"}% |
browser_major |
%BROWSERINFO{"$browser_major"}% |
browser_minor |
%BROWSERINFO{"$browser_minor"}% |
browser_beta |
%BROWSERINFO{"$browser_beta"}% |
browser_properties |
%BROWSERINFO{"$browser_properties"}% |
device |
%BROWSERINFO{"$device"}% |
device_string |
%BROWSERINFO{"$device_string"}% |
user_agent |
%BROWSERINFO{"$user_agent"}% |
Engines
engine |
%BROWSERINFO{"$engine"}% |
engine_version |
%BROWSERINFO{"$engine_version"}% |
engine_major |
%BROWSERINFO{"$engine_major"}% |
engine_minor |
%BROWSERINFO{"$engine_minor"}% |
engine_beta |
%BROWSERINFO{"$engine_beta"}% |
edgehtml |
%BROWSERINFO{"$edgehtml"}% |
gecko |
%BROWSERINFO{"$gecko"}% |
khtml |
%BROWSERINFO{"$khtml"}% |
presto |
%BROWSERINFO{"$presto"}% |
trident |
%BROWSERINFO{"$trident"}% |
webkit |
%BROWSERINFO{"$webkit"}% |
OS
Property |
Value |
os |
%BROWSERINFO{"$os"}% |
os_string |
%BROWSERINFO{"$os_string"}% |
os_version |
%BROWSERINFO{"$os_version"}% |
os_major |
%BROWSERINFO{"$os_major"}% |
os_minor |
%BROWSERINFO{"$os_minor"}% |
os_beta |
%BROWSERINFO{"$os_beta"}% |
Browsers
Property |
Value |
adm |
%BROWSERINFO{"$adm"}% |
android |
%BROWSERINFO{"$android"}% |
aol |
%BROWSERINFO{"$aol"}% |
aol3 |
%BROWSERINFO{"$aol3"}% |
aol4 |
%BROWSERINFO{"$aol4"}% |
aol5 |
%BROWSERINFO{"$aol5"}% |
aol6 |
%BROWSERINFO{"$aol6"}% |
applecoremedia |
%BROWSERINFO{"$applecoremedia"}% |
audrey |
%BROWSERINFO{"$audrey"}% |
avantgo |
%BROWSERINFO{"$avantgo"}% |
avantgo |
%BROWSERINFO{"$avantgo"}% |
blackberry |
%BROWSERINFO{"$blackberry"}% |
browsex |
%BROWSERINFO{"$browsex"}% |
chrome |
%BROWSERINFO{"$chrome"}% |
dalvik |
%BROWSERINFO{"$dalvik"}% |
dsi |
%BROWSERINFO{"$dsi"}% |
edge |
%BROWSERINFO{"$edge"}% |
edgelegacy |
%BROWSERINFO{"$edgelegacy"}% |
elinks |
%BROWSERINFO{"$elinks"}% |
emacs |
%BROWSERINFO{"$emacs"}% |
epiphany |
%BROWSERINFO{"$epiphany"}% |
firefox |
%BROWSERINFO{"$firefox"}% |
galeon |
%BROWSERINFO{"$galeon"}% |
icab |
%BROWSERINFO{"$icab"}% |
ie |
%BROWSERINFO{"$ie"}% |
ie10 |
%BROWSERINFO{"$ie10"}% |
ie11 |
%BROWSERINFO{"$ie11"}% |
ie3 |
%BROWSERINFO{"$ie3"}% |
ie4 |
%BROWSERINFO{"$ie4"}% |
ie4up |
%BROWSERINFO{"$ie4up"}% |
ie5 |
%BROWSERINFO{"$ie5"}% |
ie55 |
%BROWSERINFO{"$ie55"}% |
ie55up |
%BROWSERINFO{"$ie55up"}% |
ie5up |
%BROWSERINFO{"$ie5up"}% |
ie6 |
%BROWSERINFO{"$ie6"}% |
ie7 |
%BROWSERINFO{"$ie7"}% |
ie8 |
%BROWSERINFO{"$ie8"}% |
ie9 |
%BROWSERINFO{"$ie9"}% |
ie_compat_mode |
%BROWSERINFO{"$ie_compat_mode"}% |
iopener |
%BROWSERINFO{"$iopener"}% |
ipad |
%BROWSERINFO{"$ipad"}% |
iphone |
%BROWSERINFO{"$iphone"}% |
ipod |
%BROWSERINFO{"$ipod"}% |
kindle |
%BROWSERINFO{"$kindle"}% |
kindlefire |
%BROWSERINFO{"$kindlefire"}% |
konqueror |
%BROWSERINFO{"$konqueror"}% |
links |
%BROWSERINFO{"$links"}% |
lotusnotes |
%BROWSERINFO{"$lotusnotes"}% |
lynx |
%BROWSERINFO{"$lynx"}% |
mobile_safari |
%BROWSERINFO{"$mobile_safari"}% |
mosaic |
%BROWSERINFO{"$mosaic"}% |
mozilla |
%BROWSERINFO{"$mozilla"}% |
n3ds |
%BROWSERINFO{"$n3ds"}% |
nav2 |
%BROWSERINFO{"$nav2"}% |
nav3 |
%BROWSERINFO{"$nav3"}% |
nav4 |
%BROWSERINFO{"$nav4"}% |
nav45 |
%BROWSERINFO{"$nav45"}% |
nav45up |
%BROWSERINFO{"$nav45up"}% |
nav4up |
%BROWSERINFO{"$nav4up"}% |
nav6 |
%BROWSERINFO{"$nav6"}% |
nav6up |
%BROWSERINFO{"$nav6up"}% |
navgold |
%BROWSERINFO{"$navgold"}% |
neoplanet |
%BROWSERINFO{"$neoplanet"}% |
neoplanet2 |
%BROWSERINFO{"$neoplanet2"}% |
netfront |
%BROWSERINFO{"$netfront"}% |
netscape |
%BROWSERINFO{"$netscape"}% |
obigo |
%BROWSERINFO{"$obigo"}% |
opera |
%BROWSERINFO{"$opera"}% |
opera3 |
%BROWSERINFO{"$opera3"}% |
opera4 |
%BROWSERINFO{"$opera4"}% |
opera5 |
%BROWSERINFO{"$opera5"}% |
opera6 |
%BROWSERINFO{"$opera6"}% |
opera7 |
%BROWSERINFO{"$opera7"}% |
palm |
%BROWSERINFO{"$palm"}% |
polaris |
%BROWSERINFO{"$polaris"}% |
ps3 |
%BROWSERINFO{"$ps3"}% |
psp |
%BROWSERINFO{"$psp"}% |
pubsub |
%BROWSERINFO{"$pubsub"}% |
realplayer |
%BROWSERINFO{"$realplayer"}% |
realplayer_browser |
%BROWSERINFO{"$realplayer_browser"}% |
safari |
%BROWSERINFO{"$safari"}% |
seamonkey |
%BROWSERINFO{"$seamonkey"}% |
silk |
%BROWSERINFO{"$silk"}% |
staroffice |
%BROWSERINFO{"$staroffice"}% |
ucbrowser |
%BROWSERINFO{"$ucbrowser"}% |
wap |
%BROWSERINFO{"$wap"}% |
webos |
%BROWSERINFO{"$webos"}% |
webtv |
%BROWSERINFO{"$webtv"}% |
Windows
Property |
Value |
windows |
%BROWSERINFO{"$windows"}% |
win16 |
%BROWSERINFO{"$win16"}% |
win3x |
%BROWSERINFO{"$win3x"}% |
win31 |
%BROWSERINFO{"$win31"}% |
win32 |
%BROWSERINFO{"$win32"}% |
winme |
%BROWSERINFO{"$winme"}% |
win95 |
%BROWSERINFO{"$win95"}% |
win98 |
%BROWSERINFO{"$win98"}% |
winnt |
%BROWSERINFO{"$winnt"}% |
win2k |
%BROWSERINFO{"$win2k"}% |
winxp |
%BROWSERINFO{"$winxp"}% |
win2k3 |
%BROWSERINFO{"$win2k3"}% |
winvista |
%BROWSERINFO{"$winvista"}% |
win7 |
%BROWSERINFO{"$win7"}% |
win8 |
%BROWSERINFO{"$win8"}% |
win8_0 |
%BROWSERINFO{"$win8_0"}% |
win8_1 |
%BROWSERINFO{"$win8_1"}% |
win10 |
%BROWSERINFO{"$win10"}% |
win10_0 |
%BROWSERINFO{"$win10_0"}% |
wince |
%BROWSERINFO{"$wince"}% |
winphone |
%BROWSERINFO{"$winphone"}% |
winphone7 |
%BROWSERINFO{"$winphone7"}% |
winphone7_5 |
%BROWSERINFO{"$winphone7_5"}% |
winphone8 |
%BROWSERINFO{"$winphone8"}% |
winphone10 |
%BROWSERINFO{"$winphone10"}% |
Macs
Property |
Value |
mac |
%BROWSERINFO{"$mac"}% |
mac68k |
%BROWSERINFO{"$mac68k"}% |
macppc |
%BROWSERINFO{"$macppc"}% |
macosx |
%BROWSERINFO{"$macosx"}% |
ios |
%BROWSERINFO{"$ios"}% |
Unix
Property |
Value |
unix |
%BROWSERINFO{"$unix"}% |
sun |
%BROWSERINFO{"$sun"}% |
sun4 |
%BROWSERINFO{"$sun4"}% |
sun5 |
%BROWSERINFO{"$sun5"}% |
suni86 |
%BROWSERINFO{"$suni86"}% |
irix |
%BROWSERINFO{"$irix"}% |
irix5 |
%BROWSERINFO{"$irix5"}% |
irix6 |
%BROWSERINFO{"$irix6"}% |
hpux |
%BROWSERINFO{"$hpux"}% |
hpux9 |
%BROWSERINFO{"$hpux9"}% |
hpux10 |
%BROWSERINFO{"$hpux10"}% |
aix |
%BROWSERINFO{"$aix"}% |
aix1 |
%BROWSERINFO{"$aix1"}% |
aix2 |
%BROWSERINFO{"$aix2"}% |
aix3 |
%BROWSERINFO{"$aix3"}% |
aix4 |
%BROWSERINFO{"$aix4"}% |
linux |
%BROWSERINFO{"$linux"}% |
sco |
%BROWSERINFO{"$sco"}% |
unixware |
%BROWSERINFO{"$unixware"}% |
mpras |
%BROWSERINFO{"$mpras"}% |
reliant |
%BROWSERINFO{"$reliant"}% |
dec |
%BROWSERINFO{"$dec"}% |
sinix |
%BROWSERINFO{"$sinix"}% |
freebsd |
%BROWSERINFO{"$freebsd"}% |
bsd |
%BROWSERINFO{"$bsd"}% |
Devices
Property |
Value |
amiga |
%BROWSERINFO{"$amiga"}% |
chromeos |
%BROWSERINFO{"$chromeos"}% |
dotnet |
%BROWSERINFO{"$dotnet"}% |
firefoxos |
%BROWSERINFO{"$firefoxos"}% |
lib |
%BROWSERINFO{"$lib"}% |
mobile |
%BROWSERINFO{"$mobile"}% |
ps3gameos |
%BROWSERINFO{"$ps3gameos"}% |
pspgameos |
%BROWSERINFO{"$pspgameos"}% |
tablet |
%BROWSERINFO{"$tablet"}% |
vms |
%BROWSERINFO{"$vms"}% |
webview |
%BROWSERINFO{"$webview"}% |
windows |
%BROWSERINFO{"$windows"}% |
x11 |
%BROWSERINFO{"$x11"}% |
Robots
Property |
Value |
robot |
%BROWSERINFO{"$robot"}% |
robot_string |
%BROWSERINFO{"$robot_string"}% |
robot_id |
%BROWSERINFO{"$robot_id"}% |
robot_version |
%BROWSERINFO{"$robot_version"}% |
robot_major |
%BROWSERINFO{"$robot_major"}% |
robot_minor |
%BROWSERINFO{"$robot_minor"}% |
robot_beta |
%BROWSERINFO{"$robot_beta"}% |
all_robot_ids |
%BROWSERINFO{"$all_robot_ids"}% |
Installation Instructions
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.
Open configure, and open the "Extensions" section. "Extensions Operation and Maintenance" Tab -> "Install, Update or Remove extensions" Tab. Click the "Search for Extensions" button.
Enter part of the extension name or description and press search. Select the desired extension(s) and click install. If an extension is already installed, it will
not show up in the
search results.
You can also install from the shell by running the extension installer as the web server user: (Be sure to run as the webserver user, not as root!)
cd /path/to/foswiki
perl tools/extension_installer <NameOfExtension> install
If you have any problems, or if the extension isn't available in
configure
, then you can still install manually from the command-line. See
https://foswiki.org/Support/ManuallyInstallingExtensions for more help.
Dependencies
Name | Version | Description |
---|
HTTP::BrowserDetect | >=3.0 | Required |
Change History
27 Apr 2022 |
detect edge and edge/legacy |
19 Oct 2020 |
fixed user agent initialization |
20 May 2020 |
admins may use the ua url parameter for testing |
26 Oct 2018 |
performance fixes; all positive boolean browser properties are added to the Foswiki "context" now |
22 Oct 2018 |
initial release |