Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

browserclass

1,764 sites Security covered
View on drupal.org

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().

Activity

Total releases
1
First release
Dec 2024
Latest release
1 year ago
Release cadence
Stability
100% stable

Releases

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