BillPull
BillPull

Reputation: 7013

$browser not defined

I am trying to use jquery for browser detection but it says

Uncaught ReferenceError: $browser is not defined

the code is like

if(!$browser.msie){
   condition
 }

Upvotes: 4

Views: 12266

Answers (6)

DarthJDG
DarthJDG

Reputation: 16591

browser is a property on the main jQuery object: if(!$.browser.msie){ ... }

Please note that since the time of posting, this property has been removed in jQuery 1.9.

Upvotes: 6

user2069723
user2069723

Reputation: 167

$.browser was removed in jquery 1.9. See http://jquery.com/upgrade-guide/1.9/#jquery-browser-removed

Upvotes: 7

planetjones
planetjones

Reputation: 12633

You are missing a dot:

$.browser

Check out the documentation.

Upvotes: 2

matt b
matt b

Reputation: 140061

$browser is not defined because the browser property is defined as a part of the jQuery (or $) object.

In other words, use $.browser or jQuery.browser, not $browser.

Upvotes: 5

Edgar Villegas Alvarado
Edgar Villegas Alvarado

Reputation: 18354

It's $.browser, not $browser

if($.browser.msie) ...

Upvotes: 1

mak
mak

Reputation: 13407

Try

$.browser.msie

or

jQuery.browser.msie

Upvotes: 2

Related Questions