Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript On body click, hide search

  • This topic is empty.
Viewing 7 posts - 16 through 22 (of 22 total)
  • Author
    Posts
  • #132583
    chrisburton
    Participant

    @pixelgrid

    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.

    #132585
    pixelgrid
    Participant

    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

    #132587
    chrisburton
    Participant

    Hmm. The if/else statement isn’t working for some reason.

    #132600
    CrocoDillon
    Participant

    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.

    #132618
    TheDoc
    Member

    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.

    #132627
    CrocoDillon
    Participant

    @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.

    #132669
    chrisburton
    Participant

    Thanks, Gray for pointing that out. I’ll edit the code.

Viewing 7 posts - 16 through 22 (of 22 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.