Jasper Jasper - 6 months ago 18
Javascript Question

If not Opera Mini

This question is quite simple, but I want to ask it anyway.

This code tell us that user's browser is a famous Opera Mini

var isOperaMini = (navigator.userAgent.indexOf('Opera Mini') > -1);


So I can use it in this way:

if (navigator.userAgent.indexOf('Opera Mini') > -1)
alert('hey! your browser is buggy');


This is
if Opera Mini, then
conditional.

How do I make a right short conditional for
if not Opera mini, then
?

I'm not sure how should I play with
-1
integer.

Answer

You can simply change it to

if (navigator.userAgent.indexOf('Opera Mini') == -1)

That will return true if it does NOT find 'Opera Mini' in the user agent string

Comments