Skip to content

Instantly share code, notes, and snippets.

@lrobeson
Created December 29, 2016 19:59
Show Gist options
  • Save lrobeson/c2cdaf9978bd71b979df91594aaf61b0 to your computer and use it in GitHub Desktop.
Save lrobeson/c2cdaf9978bd71b979df91594aaf61b0 to your computer and use it in GitHub Desktop.
Add User-Agent info to HTML tag
// Add User-Agent info to HTML tag, example:
// <html data-useragent="Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)">
function addUserAgent() {
var doc = document.documentElement;
doc.setAttribute('data-useragent', navigator.userAgent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment