Information about your Web browser

Using JavaScript to identify your Opera Web browser

Some Web sites are designed to work correctly only with certain browsers, and some sites will not even let you access them unless you are using one of their approved browsers. All browsers provide information about their identity that can be queried by Web sites and computer programs, but it is not normally visible.

This Web page checks that you are using an Opera browser (versions 5 to 27), makes the information about its identity visible, attempts to determine whether it is spoofing, and attempts to display its version number.

Identify other Web browsers

Which Opera Web browser am I using?

If your browser could not be identified, or if it was identified incorrectly, then please send me a message so that I can try to improve the identification.

Spoofing

Some Web browsers can be configured to supply identification that belongs to other browsers, a process known as spoofing. This can allow browsers to access Web sites that attempt to restrict access to specified browsers. Perfect spoofing would be impossible to detect.

Opera 5–12

Opera browsers from version 5 to version 12 always have a JavaScript object called window.opera, and this allows them to be detected when they pretend to be Internet Explorer or other browsers. To set up spoofing for a particular Web site:

  1. Go to the Web site where you want Opera to pretend to be another browser.
  2. If you are using Windows, press F12 to open the Quick Preferences menu.
    If you are using Mac OS X, select Quick preferences on the Opera menu.
  3. Select Edit Site Preferences….

    Edit Site Preferences…

  4. In the Site Preferences dialog box, select the Network tab.
  5. Select an identity in the drop-down list below “Browser identification”.

    Setting Opera to spoof as Internet Explorer

  6. Note that “Identify” includes Opera in the identification data, while “Mask” does not.
  7. Select OK.

How are you identifying my Opera browser?

There are several ways of identifying a browser, but this page uses some fairly simple JavaScript that someone without programming experience can understand and modify.

The first step is to make sure that you are using either Opera version 5–12 (by checking for the presence of the JavaScript window.opera object) or Opera version 15 or later (by checking for the presence of “Opera” in the navigator.vendor object). If neither of these is found, then a message and a link to the main browser identification page will be displayed.

if (! window.opera)
{
document.write("<p><strong>You do not appear to be using an Opera Web browser.<\/strong><\/p>");
}

The second step is to retrieve the userAgent data that your Opera browser supplies as part of the JavaScript navigator object, for example:

Mozilla/5.0 (Windows NT 5.1; U; en; rv:1.8.1) Gecko/20061208 Firefox/2.0.0 Opera 9.64

The third step is to convert the data to lower case and search it for one or more strings of characters whose presence and/or absence (alone or in combination) can be used to detect spoofing and to identify a browser. For example, the following definition specifies the presence of “firefox/2”.

else if (navigator.userAgent.toLowerCase().indexOf("firefox/2") != -1)

This indicates that your Opera browser is configured to spoof as Firefox 2, and so when a match is found, this causes the next piece of JavaScript to write some HTML that displays a message as part of the Web page:

document.write("<p><strong>Your Web browser claims to be Firefox version 2, but appears to be Opera providing a false identity<\/strong><\/p>");

The fourth step is to check for a string that indicates the browser version, for example:

else if (navigator.userAgent.toLowerCase().indexOf("opera 9.6") != -1)

Finding a match causes the final piece of JavaScript to write some HTML that displays a message about the version as part of the Web page:

document.write("<p><strong>Your version of Opera appears to be 9.6<\/strong><\/p>");

This type of identification is not completely accurate, especially when browsers pretend to be other browsers, but it works most of the time.

Send comments or questions to Alan Wood

Valid HTML 4.01     Unicode Encoded
Created 20th December 2001   —   Updated 10th May 2015
Copyright © 2001–2015 Alan Wood

Alan Wood’s Web site