Reputation: 1415
I updated my jQuery from 1.3.2 to latest 2.1.0
Now I noticed I have this error on my page:
TypeError: Cannot read property 'safari' of undefined
And here is my code that has this:
if(p=='marginRight'&&$.browser.safari)
and
if($.browser.safari){this.buttons(false,false);
I read that from version 1.9 $.browser has been removed, can somebody please help, how can this be fixed? I googled and tried some things but didn't seem to find the right thing..
Thank you
Upvotes: 0
Views: 77
Reputation: 3269
The jQuery.browser() method has been deprecated since jQuery 1.3 and is removed in 1.9. If needed, it is available as part of the jQuery Migrate plugin. We recommend using feature detection with a library such as Modernizr.
Reference: http://jquery.com/upgrade-guide/1.9/#jquery-browser-removed
Since it has been removed your most simple option here is to use jquery migrate
Upvotes: 0
Reputation: 283043
The easiest way is to just include jquery-migrate. This patches in all the functions they removed.
Otherwise, you have to rewrite your code to avoid browser detection. Generally, feature detection is recommended over browser sniffing.
Upvotes: 1
Reputation: 5795
you can detect browsers via native navigator
object
if(navigator.userAgent.indexOf("Safari") > -1) {
// safari
}
Upvotes: 1