mail us  |  mail this page

products  |  company  |  support  |  training  |  contact us

Changing Browser User Agent Strings

CCBot/2.0

OK we admit it - the above is a cheap one line trick using apache SSIs.

We produced this page not because we think changing browser User Agent strings is a good idea - in fact we think it is an incredibly bad idea unless you absolutely need to do it (some sites do not display well, or even at all, if they fail to recognize your browser). But we got mail recently saying someone was having a problem viewing our pages. Turns out it was a badly configured - not deliberately cloaked - UA string. So we got to thinking how could we help fix the problem - and as usual we had no idea! We use server-side browser sniffing to serve browser specific page content - mostly 'cos we want to progressively phase out - or a least minimise - development for non-W3C conformant browsers while pushing ahead with conformant browsers (truth be told we used to feel very strongly about this until the great HTML5 betrayal. Now - meh). Depending on which browser you use you will see a different ZyTrax site - well at least as far as navigation is concerned. 'Nuff said. So here for Opera, Moz and the clones, which unless identified specifically includes Firefox, K-Meleon (great stuff), Galeon, Epiphany etc., etc. and, of course, MSIE and Chrome is some info about changing UA strings.

Opera

Opera 11

In Opera 11 you have to make a Panel visible by clicking the < button at the bottom left of the browser window. Then click the + symbol from the Panel and choose 'Customize...'. In the window that opens select the 'Button' tab then 'Preferences' and drag the 'Identify as Opera' combo box onto the top browser bar. It provides three options: Identify as Opera; Identify as Firefox; Identify as Internet Explorer.

Opera 9

Opera 9 Removed browser change from the Quick Preferences menu - instead use Tools->Quick Preferences->Edit Site Preferences->Select Network Tab->Use Browser Identification combo box.

Opera 7 and 8

Opera 7+ provides a feature to change the UA string from the menu:

Use Tools->Quick Preference and select the browser you want to emulate from the radio button list at the foot of the menu. Or if you like lots of clicking use Tools->Preferences->network then select from the drop down menu under 'Browser Identification'.

Opera 9 Removed browser change from Quick Preferences menu - instead use Tools->Quick Preferences->Edit Site Preferences->Select Network Tab->Use Browser Identification combo box.

Notes:

  1. Opera 7 & 8 default to MSIE identification - which means on our site you will not get our great css menus unless you change to a Moz string - and they have worked perfectly since Opera 7.54. Opera 9 defaults to Opera identification.

  2. Even if you select MSIE (and we assume Mozilla) you get a Opera x.yy string at the end - which some sites object to - not us we just ignore it, actually we ignore most things. You can remove even this vestigial (wow!) string in Opera 8 but not Opera 7. Opera call this cloaked mode. Cloaked mode can only be configured by using the ua.ini file discussed below and it can even be set on a site-by-site basis.

  3. From Opera 8 there is a nifty file called ua.ini (in the same directory as your Opera profile - typically %SystemRoot%\accountname\Application Data\Opera\Opera\profile\ua.ini) in which you can specify any string, including a cloaked string, for either Mozilla or MSIE on a site by site basis (Opera info on this topic - under miscellaneous). Note: if you set a value in the ua.ini file it trumps the menu setting to change identifier. Clicking the menu setting until your fingers bleed will have no effect - the value from the ua.ini will always be used depending on what values you set. The default values in this file are clearly set based on reported site problems. Annotated ua.ini file.

  4. Finally with Opera 8 there is also a snazzy feature to allow you to play with Javascript variables so you can pretend to be a real MSIE browser to client side browser detection routines (Opera info on this topic).

Microsoft Internet Explorer

MSIE 8 and 9

The change UA features provided by these versions are extremely flexible and safe to use. To invoke the feature press the F12 key in any page (or click the '*' button on the top extreme right and select 'F12 Developer Tools'). From the resulting window click the Tools menu, select 'Change user agent string' and select a canned string from those provided (various MSIE versions, FF, Chrome, Opera and Bing) or select 'Custom..' which allows you to define any string that will subsequently be added to the available menu. A very comprehensive feature set and relatively easy to use.

MSIE 7

Unknown.

MSIE 6

The basic UA string cannot be changed. Any additional values displayed in the MSIE UA string are defined in the registry. Use Start->Run enter regedit then navigate to the following key:

HKEY_LOCAL_MACHINE\software\Microsoft\Windows\CurrentVersion\
    Internet Settings\User Agent

Adding new strings here will cause the name of the field - not the data content to be appended to the UA string. The basic string is left intact.

To change the basic string add (if not present) the following key:

HKEY_LOCAL_MACHINE\software\Microsoft\Windows\CurrentVersion\
    Internet Settings\5.0\User Agent
                          (default) "Mozilla/4.0"
                          Compatible "compatible"
                          Version "MSIE 6.0"
                          Platform "Windows NT 4.0"

The default value will replace the Mozilla/4.0 string that MSIE uses. You can add Compatible, Version and Platform strings as shown above and described in this MSDN article. The article also explains how to add Post Platform and Pre Platform values.

Warning: Messing around with the registry can seriously damage your system and your mental health. Do not do do it unless you know exactly what you are doing. Then think twice.

Moz Family

You can get a user agent switcher extension (alternative site) or do it the hard way as shown below.

Enter about:config in the address line and it will display a full list of the variables used. In the filter line type useragent - and if you are lucky there will be a string identified with general.useragent.override - to modify just double click the entry and make your required changes.

However in a standard Firefox install this variable is not present so you will have to add it to the Prefs.js file in your profile directory.

user_pref("general.useragent.override","Some string");

Notes:

  1. With some helpful hints from John Dobson - thanks.
  2. Close Firefox before editing the Prefs.js file.
  3. Some information says use user_pref and others just pref in the Prefs.js file - it does not seem to matter except the entry will be bolded and marked user set in about:config if you use user_pref.
  4. This change is permanent - to change it back to the default remove the line in Prefs.js, or use about:config and double click the entry to change it to something else.
  5. Typical browser strings can be found in the main page under the relevant browser - just cut and paste
  6. If you define an MSIE string such as Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0) and you have the Java Plugin installed (use about:plugins to verify) the most likely result is that your browser will crash on loading with a message telling you to use the MS Java run time. To fix this problem before you modify the Prefs.js file use Tools->Options->Web Features and disable (uncheck) enable Java. Close Firefox, add the above line then reload Firefox. If you have read this note after your browser has crashed - remove the useragent entry from Prefs.js , load Firefox, disable Java, close Firefox, add the line in Prefs.js, then reload Firefox. All will be well - unless you want to use Java that is!

Chrome

Chrome (as of version 26) provides an updated sneaky (in the sense that it is well hidden) and broken (does not work) method to change the UA. Click the Customize and Control icon (now 3 lines - good to see google constantly improving their UI to make it more intuitive) in the top right of the main window and select Tools-> Developer Tools from the menus. This opens a split screen at the bottom of the page. Click the settings icon (a gear icon on the extreme bottom right - just to keep you guessing), click Overrides on left hand menu, then check User Agent and select your favorite (should that be least objectionable) browser ID string from the combo box. And all of this has no effect - it does not work. It is broken, non-functional, ineffective and does nothing. It could even be called a bug (it also creates some very strange string based on the combo box selection but this could be a further reflection of its brokeness).

Chrome (as of version 17) provides a sneaky (in the sense that it is well hidden) method to change the UA. Click the Customize and Control icon (a spanner) in the top right of the main window and select Tools-> Developer Tools from the menus. This opens a split screen at the bottom of the page. Click the settings icon (a gear icon on the extreme bottom right - just to keep you guessing), check Override User Agent and select your favorite (should that be least objectionable) browser ID string from the combo box.

Bizarrely, Chrome (as of version 11) does not offer any easy way to modify its UA string. Instead you have to use a command line switch of the form "--user-agent="replacement string". Equally bizarrely, on Windows Chrome's executable (chrome.exe) does not reside in the normal Program Files or Program Files (x86) directories instead it resides in Users\username\AppData\Local\Google\Chrome\Application (Vista and Windows 7) and which apparently translates to Documents and Settings\username\Local Settings\Application Data\Google\Chrome in XP. You either need to open a command prompt window, navigate to the above location and then enter chome.exe --user-agent="string" (life is too short to do that twice) or create a shortcut to chrome.exe in the above directory and edit the short cut (right click, select properties) and add the appropriate --user-agent="string", then rename the shorcut to reflect the browser string and drag it onto your desktop or some equally appropriate place. Repeat as often as needed to cover your favorite alternative strings.



Problems, comments, suggestions, corrections (including broken links) or something to add? Please take the time from a busy life to 'mail us' (at top of screen), the webmaster (below) or info-support at zytrax. You will have a warm inner glow for the rest of the day.

Tech

tech home
audio stuff
web stuff
dom stuff
css stuff
language stuff
regex stuff
rfc stuff
protocol stuff
cable stuff
lan wiring
rs232 wiring
howto stuff
survival stuff
wireless stuff
ascii codes
Dec > Hex > Bin
data rate stuff
telephony stuff
mechanical stuff
pc stuff
electronic stuff
tech links
open guides
RSS Feed Icon RSS Feed

If you are happy it's OK - but your browser is giving a less than optimal experience on our site. You could, at no charge, upgrade to a W3C STANDARDS COMPLIANT browser such as Mozilla

web zytrax.com

Share Page

share page via facebook tweet this page submit page to stumbleupon submit page to reddit.com

Page Features

Page comment feature Send to a friend feature print this page Decrease font size Increase font size

HTML Stuff

W3C HTML 4.01
HTML5 (WHATWG)
HTML4 vs HTML5
HTML5 Reference
W3C Page Validator
W3C DOCTYPE

CSS Stuff

W3C CSS1
W3C CSS2.1

DOM Stuff

W3C DOM
W3C DOM Events
Gecko DOM
MSIE DOM

Usability/Access

usability.gov
W3C -WAI
Web Style Guide
Michael L Bernard
WebAim.org

Jolly Useful

Peter-Paul Koch
A List Apart
Eric Meyer on CSS
glish.com
DOCTYPE definitions

Our Stuff

Our DOM Pages
DOM User Guide
DOM Explorer
DOM Navigation
CSS Techniques
CSS Short Cuts
CSS overview
Oh Really!

Javascript

ECMA-262

Pop-out Menus

webmasterbase.com
Brainjar Menubar
Our Lite JS Menus
Our CSS Menus
Tigra Menus

printer friendly

Print Page

SPF Record Conformant Domain Logo

Copyright © 1994 - 2013 ZyTrax, Inc.
All rights reserved. Legal and Privacy
site by zytrax
Hosted by super.net.sg
web-master at zytrax
Page modified: April 18 2013.