Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Facets 3.0.6 Minor update available for module facets (3.0.6). Release: Facets 3.0.5 Minor update available for module facets (3.0.5). Release: Flag 5.1.0 Minor update available for module flag (5.1.0). Release: Ágora Transparency Theme 1.0.7 Minor update available for theme agora_theme (1.0.7). Release: Automated Revision Log 1.1.3 Minor update available for module ai_revision_log (1.1.3). Release: Views HTTP Client 1.0.4 Minor update available for module views_http_client (1.0.4). Release: Block Layout Accordion 1.0.2 Minor update available for module block_layout_accordion (1.0.2). Release: Canvas interactive toggle 1.0.2 Minor update available for module canvas_interactive_toggle (1.0.2). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Browser Class

1,758 sites Security covered Drupal 8–11
View on drupal.org

This module helps theme developers create cross-browser compatible websites by adding browser and platform information as CSS classes to the body tag. It also provides tokens for including this browser information in error reports and allows developers to add custom classes.

Summary

This small module helps theme-developers to deal with cross-browser compatibility. It makes easier to handle different types of non-widespread browsers just as much as it helps with using different versions of Internet Explorer.
The module extends the $body_classes variable in page.tpl.php based on the enduser's browser, and platform.

The module also makes a $browser_classes variable available in page.tpl.php, which stores the data in an array, this way the developer can make use of it as needed, if he does not wish to use the $body_classes variable.

Supported browsers

  • ie
  • opera
  • safari
  • chrome
  • netscape
  • ff
  • konqueror
  • dillo
  • chimera
  • beonex
  • aweb
  • amaya
  • icab
  • lynx
  • galeon
  • operamini

Browser version checking

The module creates version classes.

  • ie[version]
  • opera[version]
  • chrome[version]
  • safari[version]
  • netscape[version]
  • ff[version]
  • konqueror[version]
  • operamini[version]

Supported platforms

  • win
  • ipad
  • ipod
  • iphone
  • mac
  • android
  • linux
  • nokia
  • blackberry
  • NetBSD
  • FreeBSD
  • OpenBSD

Mobile detecting

The module checks if the device is mobile and adds "mobile" or "desktop" class.

Token support

The module creates tokens, which will be greatly helpful when a user reports a site problem and a site administrator will receive a message with details regarding the user, including his/her browser class .
See the full discussion at #1052858: token for user's browser.

Currently available tokens

  • The current user's browser classes: [browserclass]
  • Browser type: [browserclass-browser]
  • Platform: [browserclass-platform]
  • Device info: [browserclass-mobile]
  • Extra hook classes: [browserclass-hook-classes]

Configuration

The module has a settings page, where the administrator can choose between these options:

  • always add the class with JavaScript
  • only use JavaScript if page cache is enabled

This is a fallback option for JS disabled browsers, and no JavaScript will run on page load if it's not necessary.

Example

In html:

<body class="... chrome chrome11 mac desktop">
...
</body>

In css:

body.chrome.mac p {
  font-size: 11px;
}

Developers

Developers can add their own classes with hook_browserclass_classes().

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
1
Tracked since
Dec 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Core Release date
8.x-1.1 Stable 8–11 Dec 6, 2024