I need to change a value based on each browser since they all render differently.
if (navigator.appName == 'Netscape'){
top = 17;
}
This was working but unfortunately both Firefox and Safari show up as "Netscape"
How would I use jQuery 1.3.2 to detect all these? I couldn't find any info under jquery.support
now that jquery.browser
is gone.
Thanks!
I need to change a value based on each browser since they all render differently.
if (navigator.appName == 'Netscape'){
top = 17;
}
This was working but unfortunately both Firefox and Safari show up as "Netscape"
How would I use jQuery 1.3.2 to detect all these? I couldn't find any info under jquery.support
now that jquery.browser
is gone.
Thanks!
Share Improve this question edited Sep 30, 2009 at 16:19 Dan Herbert 104k51 gold badges192 silver badges221 bronze badges asked Jun 2, 2009 at 21:53 novonnovon 2412 gold badges4 silver badges11 bronze badges5 Answers
Reset to default 5If you must have browser detection (despite the warnings against it), ppk's routine is current (even up through Chrome and iPhone).
Are you, or have you considered, using a reset.css
stylesheet to set all browsers' defaults to zero? If not I remend you do so since it might solve your current problem, as well as potential future ones.
It may help because it would set all browsers to a baseline zero, so when you apply padding or positioning, it should have the same effect in all browsers.
What are they rendering differently? Is there a way you can use capability detection rather than browser sniffing? It's less prone to breakage when new browsers e along, and more tolerant of the fringe.
you can use the jQuery.browser
object. It's deprecated in jQ 1.3 in favour of the jQuery.support
, but there's no immediate plans to remove it altogether, so you should be safe.
That said, using browser sniffing, while very easy and tempting, isn't usually the best way to do things. Since it sounds like you're having problems with some browsers doing CSS differently, you might want to look at jQuery.support.boxModel
.
They all renders the tooltip's top css value differently.
var container = $('<div id="personPopupContainer">'
+ '<div id="personPopupContent">'
+ '</div>'
+ '</div>');
var pos = $(this).offset();
var width = $(this).width();
var reposition = { left: (pos.left - width) + 'px', top: pos.top + msg + 'px' };
container.css({
top: reposition.top
});