Forums
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › On body click, hide search
Couldn’t I do something like this:
$(‘.find’).click(function(event) {
event.preventDefault();
if ($.browser.msie) {
$(‘.search’).slideDown(‘slow’);
}
else {
$(‘.search’).slideDown(‘slow’).focus();
}
});
It doesn’t seem to work but you get what I mean.
sure you can do the sliding effects like that but keep in mind that since jquery 1.9 $.browser is removed.
So be sure the version you are using is lower than 1.9.Also navigator.userAgent might help you
actually not slide down but the animate function in my pen
Hmm. The if/else statement isn’t working for some reason.
You can maybe try
if (navigator.appName == ‘Microsoft Internet Explorer’)
tested on IE9 and IE10. `$.browser` is removed as @pixelgrid said, downgrading your jQuery just to get that back seems not like a valid option to me, though if you did… I’m puzzled why it wouldn’t work.
This thread morphed too quickly for me to be able to respond haha.
My 2c: definitely don’t like the browser sniffing being discussed here, personally.
Also, you don’t need `e.preventDefault();` on the `.find` click function because it’s not an anchor, so there’s no default functionality you need to override.
@TheDoc, I agree on browser sniffing but for this the worst thing that could happen is the input gets focused for future IE versions if they ever decide to go with Netscape as `navigator.appName` like other vendors do.
Thanks, Gray for pointing that out. I’ll edit the code.