PDA

View Full Version : browser detect


alaios
08-11-2002, 09:23 PM
I WANT TO DETECT THE USERS BROWSER. cAN I DETECT THE OPERA BROWSER?

jkd
08-11-2002, 10:05 PM
Only reliable way to detect Opera:

if (typeof window.opera != 'undefined') {
// using opera
}

BTW, no need for yelling (caps) :).

alaios
08-12-2002, 05:06 PM
and if i want to detet and the version?

ShriekForth
08-12-2002, 06:05 PM
navigator.appVersion

You will probably want to parse that value out, parseFloat to see minor versions and parstInt to see major versions

parseFloat(navigator.appVersion)
parseInt(navigator.appVersion)


ShriekForth

Skyzyx
08-13-2002, 05:44 AM
function operaVersion()
{
if (navigator.userAgent.indexOf('Opera') != -1)
{
var opVer=navigator.userAgent; // Something to start with
if (opVer.indexOf('Opera/') != -1) opSplit=opVer.split('Opera/'); // If Opera is identifying as itself, use this.
else opSplit=opVer.split('Opera'); // If Opera is identifying itself as anything else, use this.
var opVerParsed=parseFloat(opSplit[1]); // Find the version number as a numeric instead of a string.

if (opVerParsed.toString().length==1) opVerParsed+=".0"; // For Opera 6, display Opera 6.0

document.write(opVerParsed);
}
}