mail us  |  mail this page

products  |  company  |  support  |  downloads  |  isp services  |  contact us

Changing Browser User Agent Strings

CCBot/1.0 (+http://www.commoncrawl.org/bot.html)

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 thing it is an incredibly bad idea unless you absolutely need to do it. But we got mail recently saying someone was having a problem viewing our pages. Turns out it was a badly configured - not deliberate - UA string. So we got to thinking how could we help fix the problem - and 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. If you visit this site with a sensible browser (read non-MSIE or pretending to be MSIE), you will see a different site - well at least as far as navigation is concerned. 'Nuff said. So here for Opera, Moz and the clones ,unless identified specifically that includes Firefox, K-Meleon (great stuff), Galeon, Epiphany etc., etc. and, of course, MSIE is some info about changing UA strings.

Opera

Version 9 seems to have brought with it a number of changes - see notes below.

The easiest of all since Opera 7+ provides a feature to do just that:

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, well 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 which 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).

MSIE

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.

Moz Family

You can get a user agent switcher extension 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!


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
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
add page to facebook add page to technorati.com add page to digg.com add page to del.icio.us add page to furl.net add page to stumbleupon add page to reddit.com mail this page feature print this page

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 - 2010 ZyTrax, Inc.
All rights reserved. Legal and Privacy
site by zytrax
Hosted by super.net.sg
web-master at zytrax
Page modified: November 03 2007.