Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Opera browser

Opera browser identification by starway
Posted: 30 Jan 02

Opera browser is known for it's ability to "spoof" browser name detection when navigator.appName property is used. It's not some "hidden" function but one of common preferences that any user can change by his wish. For example, user of the latest official Opera 6.0 release has several default options of it's browser identification. The options are as follows:
  • Identify as Opera
  • Identify as Mozilla 5.0
  • Identify as Mozilla 4.76
  • Identify as Mozilla 3.0
  • Identify as MSIE 5.0 (default)
If you try to detect the browser used by your visitor by checking the value of navigator.appName you may be wrong - in Opera case you can get any of above mentioned ones. But it's still Opera!

There are several ways to detect the real values, one of them is checking the value of navigator.userAgent. Here what I got using Opera 6.0 on Win2k system:

Id as Mozilla 5.0:    Mozilla/5.0 (Windows 2000; U) Opera 6.0 [en]

Id as Opera:        Opera/6.0 (Windows 2000; U) [en]

Id as MSIE 5.0:    Mozilla/4.0 (compatible; MSIE 5.0; Windows 2000) Opera 6.0 [en]

You may see that each string contains "Opera" substring, that tells you exactly what browser are you dealing with. Also, there's an option to see what type is Opera "pretending" to be at this moment. navigator.appName is good enough for this. We can perform some check-ups like these:

if ( navigator.userAgent.indexOf("Opera") !=-1 )    // this is Opera

if (( navigator.userAgent.indexOf("Opera") !=-1 ) && ( navigator.userAgent.indexOf("MSIE") !=-1))    //this is Opera identified as IE

if (( navigator.userAgent.indexOf("Opera") !=-1 ) && ( navigator.appName == "Opera" ))    // pure Opera!

The results will give us the full picture.
There's also another way to find out whether it is Opera or not. Check the folowing:


Of course, it will be true only in Opera case. The use of this property of window object in Opera browser let us know what we deal with (without getting into details):
var opera = (window.opera ? true : false)

In order to know other details, like what Opera tries to tell you about itself, you have to combine these sample codes for window.opera and navigator.userAgent mentioned above.

Opera is very easy to use for development as it's also known for various standards compliance. But there are differences between it and other browsers, and sometimes it's important to use them.

Hope this will help you to develop more cross-browser websites.
Good luck.

Back to Javascript FAQ Index
Back to Javascript Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close