var userAgent = navigator.userAgent.
$.browser.chrome = /chrome/.test(navigator.
var version = 0;
// Is this a version of IE?
if($.browser.msie){
userAgent = $.browser.version;
userAgent = userAgent.substring(0,
version = userAgent;
}
// Is this a version of Chrome?
if($.browser.chrome){
userAgent = userAgent.substring(userAgent.
userAgent = userAgent.substring(0,
version = userAgent;
// If it is chrome then jQuery thinks it's safari so we have to tell it it isn't
$.browser.safari = false;
}
// Is this a version of Safari?
if($.browser.safari){
userAgent = userAgent.substring(userAgent.
userAgent = userAgent.substring(0,
version = userAgent;
}
// Is this a version of Mozilla?
if($.browser.mozilla){
//Is it Firefox?
if(navigator.userAgent.
userAgent = userAgent.substring(userAgent.
userAgent = userAgent.substring(0,
version = userAgent;
}
// If not then it must be another Mozilla
else{
}
}
// Is this a version of Opera?
if($.browser.opera){
userAgent = userAgent.substring(userAgent.
userAgent = userAgent.substring(0,
version = userAgent;
}
//return version;
}
How to use:
detectBrowserVersion();
if ($.browser.chrome || $.browser.safari) {
//navigation detection in Chrome browser
$(document).keydown(function( e){
dokeypress(e);
});
} else {
//detect keypress
$(document).keypress(function(e){
dokeypress(e);
});
}
if ($.browser.chrome || $.browser.safari) {
//navigation detection in Chrome browser
$(document).keydown(function(
dokeypress(e);
});
} else {
//detect keypress
$(document).keypress(function(e){
dokeypress(e);
});
}
No comments:
Post a Comment