Last active
May 12, 2020 13:40
-
-
Save chriswagoner/9bc47ecea1c255a2d357fb1808f099e1 to your computer and use it in GitHub Desktop.
Beaver Builder: Add User Agent & Platform to HTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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