DetectBrowser

Summary: detect what browser your visitor is using
Version: 2009-12-29
Prerequisites:
Status:
Maintainer:
Discussion: DetectBrowser-Talk

Questions answered by this recipe

  • How can I tell what browser a visitor is using via PmWiki markup?
  • Can I check to see if a visitor is using a specific browser?

Description

check to see what browser your visitor is using.

Notes

Add to config.php: include_once("$FarmD/cookbook/detect.browser.php");

I'm sure there are many ways to do this, so feel free to amend or change the recipe if you know better.

This is very simple code that provides several ways to check which browser a visitor is using:

  • Once installed, the PageVar {$browserInfo} will return whatever's stored in $_SERVER['HTTP_USER_AGENT']
  • {(detectbrowser)} - using no argument is exactly the same as using {$browserInfo}, and will return the content of $_SERVER['HTTP_USER_AGENT']
  • {(detectbrowser browser)} - supplying one of the common browser abbreviations (i.e. firefox, safari, MSIE, etc) will return either true or false (as a string)

Examples

(:if {(detectbrowser MSIE)}:)are you sure you want to use Internet Explorer to view this site?(:ifend:)

Release notes

2009-12-30 - initial release

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See also

is there another recipe that does this already? couldn't find one...

Contributors

overtones99

Comments

See discussion at DetectBrowser-Talk

User notes : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.