Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

Browscap provides an improved version of PHP's get_browser() function.

The get_browser() function can be used to tell what a visitor's browser is capable of. Unfortunately, the version provided by PHP has a number of limitations, namely:

  • It can be difficult or impossible to configure for shared hosting environments.
  • The data used to identify browsers and determine their capabilities requires consistent maintenance to keep up-to-date.

Browscap automates maintenance by storing browser data in a database and automatically retrieving the latest data on a configurable schedule.

Requirements

Browscap requires that your server be able to "phone out" (make a http request) to retrieve and update its user agent database.

Note: Some hosting companies have this capability blocked.

Installation

Browscap can be installed via the standard Drupal installation process.

API

Modules can make use of browscap data by calling browscap_get_browser() anywhere they would otherwise call the PHP get_browser() function.

Note: browser_name_regex is not returned.

What to do if a browser is not detected properly?

Please file an issue with the browscap data. Of course, you should search for an existing issue first.

Since browscap is a server-side behavior that runs in php it will only alter behavior of your Drupal page if page caching is not active. Page caching can be disabled in the administration area and is inactive for all authenticated users.

Drupal 8/9/10

For getting info about the browser - $info = \Drupal::service('browscap')->getBrowser();. There is also a hook to alter returned values - hook_browscap_properties_alter(&$properties, $user_agent).
There are some module configs that can be useful on the /admin/config/system/browscappage.

Related Modules

A number of modules and themes integrate with Browscap, including:

Related Modules

Theme switching

  • Mobile Tools uses Browscap to get data about whether a visitor is on a mobile device.
  • Switchtheme uses Browscap to switch the site theme based on the user agent of a visitor.
  • Mobile Switch provides a simple automatic theme switch functionality for mobile devices, detected by browscap.
  • ThemeKey ThemeKey allows you to define simple or sophisticated theme-switching rules which allow automatic selection of a theme depending on current path, taxonomy terms, language, node-type, and many, many other properties.

Page layout configuration

  • Browscap Block allows blocks to be shown or hidden depending on if the site visitor is using a desktop or mobile browser.
  • Browscap CTools allows panel panes to be shown or hidden depending on if the site visitor is using a desktop or mobile browser.

Themes

  • AdaptiveTheme integrates with Browscap to allow regions to be unset or blocks to change regions when the theme is viewed on a mobile device.

Sponsors

Development of Browscap is sponsored by Acquia and the Ontario Ministry of Northern Development and Mines.

A special thanks goes out to Gary Keith who provides regular updates to the browscap user agent database, and specifically for adding a non-zipped CSV version of browscap to support this module.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
4
Tracked since
Feb 2024
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core Release date
8.x-3.0-beta4 Pre-release Mar 1, 2024
8.x-3.0-beta3 Pre-release Mar 1, 2024
8.x-3.0-beta2 Pre-release Mar 1, 2024
8.x-3.0-beta1 Pre-release Feb 29, 2024