Reputation: 927
Following code changes property printed (when accessed through javaScript) by browser console and not the actual Use-Agent string sent with the header.
Object.defineProperty(navigator, 'userAgent', {
get: function () { return 'Mozilla/5.0 (Windows NT 6.2; WOW64;
rv:28.0) Gecko/20100101 Firefox/28.0)'; }
});
Upvotes: 4
Views: 9116
Reputation: 1016
This is now possible to do, see: https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name You can use ‘ XMLHttpRequest.setRequestHeader(User-Agent, value)’
Upvotes: 5
Reputation: 163262
This isn't possible from the page itself. The user agent string (as sent in the HTTP request headers) can only be changed via browser extension or browser configuration.
Upvotes: 3