Skip to content

Instantly share code, notes, and snippets.

@chriswagoner
Last active May 12, 2020 13:40
Show Gist options
  • Select an option

  • Save chriswagoner/9bc47ecea1c255a2d357fb1808f099e1 to your computer and use it in GitHub Desktop.

Select an option

Save chriswagoner/9bc47ecea1c255a2d357fb1808f099e1 to your computer and use it in GitHub Desktop.
Beaver Builder: Add User Agent & Platform to HTML
// In Beaver Builder, we want to inject the browser and platform into the HTML tag so we can target specific browsers and/or platform in a simple manner.
// Open Beaver Builder > Open Global Settings > Javascript Tab > Paste Below Snippet
// Credit: https://codepen.io/samiah/pen/NgQKMb
jQuery(function() {
var b = document.documentElement;
b.setAttribute('data-useragent', navigator.userAgent);
b.setAttribute('data-platform', navigator.platform );
b.className += ((!!('ontouchstart' in window) || !!('onmsgesturechange' in window))?' touch':'');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment