Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#10226 closed enhancement (duplicate)

$.browser

Reported by: [email protected] 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

Change History (2)

comment:1 Changed 12 years ago by addyosmani

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.

comment:2 Changed 12 years ago by addyosmani

Duplicate of #10210.

Note: See TracTickets for help on using tickets.