Skip to main content

Bug Tracker

Side navigation

#10226 closed enhancement (duplicate)

Opened September 08, 2011 04:02AM UTC

Closed September 08, 2011 06:07AM UTC

Last modified September 08, 2011 06:07AM UTC

$.browser

Reported by: godligift@gmail.com Owned by:
Priority: low Milestone: None
Component: support Version: 1.6.3
Keywords: Cc:
Blocked by: Blocking:
Description

You are getting answer #10210. But in it's answer, don't relesation is my problem.

Take posible. I'm testing in IE


alert($.browser.msie);

giving - true.


alert($.browser.opera);

in browser IE giving "unindeferent". Is resault logical structure for one's browser. Testing ro 1.6.3 and testing 1.4.2

Attachments (0)
Change History (2)

Changed September 08, 2011 06:07AM UTC by addyosmani comment:1

component: unfiledsupport
priority: undecidedlow
resolution: → duplicate
status: newclosed

In your original ticket, you mentioned that the output you were getting when alerting $.browser.msie and $.browser.opera was a value of 'undefined'.

If you test this (http://jsfiddle.net/ZupAr/) in Opera, you'll find that msie returns 'undefined' and if you test it in Firefox you'll find that both values return undefined.

This is expected behaviour. We *expect* IE to return a value of undefined against a UA test for Opera through $.browser. To use $.browser correctly, all you need to do is check against a particular value expected as follows:

if($.browser.msie){  //returns true if IE, undefined if not (ie. not true/false)
    //do something
}else{
   //not in IE, do something else
}

the same could be said for any other browser. Test against the value you know will return positive when used with a specific browser and then just fallback on the 'else' is the value isn't true.

I notice that this is an enhancement request. Because we've been returning a value of undefined for quite some time and the plans are to deprecate $.browser and move it into its own plugin in the future, I don't think it makes sense for this behaviour to be altered. We may however document further what is returned to avoid future confusion.

Changed September 08, 2011 06:07AM UTC by addyosmani comment:2

Duplicate of #10210.