Applying onscroll to an <input> tag in FF

Discussion in 'Javascript' started by bizt, Sep 2, 2009.

  1. bizt

    bizt Guest

    Hi,

    I have a site that Im working on where we have an input tag which has
    a numeric value. Say that value is 1, I want to apply an event handler
    where if the mouse scroll wheel is scrolled up it will go 2. If they
    do a long scroll it will go 2,3,4,5,6,7,8... Obviously this involved
    me capturing the event and direction.

    In IE, we use something like:

    <input onmousewheel="doInputScroll(event, this);"...

    ... allows me to capture the event but onmousewheel is only supported
    by IE. In Firefox I found onscroll as well as some functions on how to
    capture the direction but event handler can only be applied to certain
    HTML elements however the only element I had any luck with was <body>.
    I did consider wrapping my input element in a <div> and applying the
    event handler to that but it didn't seem to work either for some
    reason anyway.

    Does anyone have any ideas how I might get this working? Its not
    common functionality I know but many of our web users are used to this
    feature in IE and it would be great to put this over to FF too

    Cheers
    Burnsy
    bizt, Sep 2, 2009
    #1
    1. Advertising

  2. bizt

    abozhilov Guest

    On Sep 2, 5:35 pm, bizt <> wrote:
    > Hi,
    >
    > I have a site that Im working on where we have an input tag which has
    > a numeric value. Say that value is 1, I want to apply an event handler
    > where if the mouse scroll wheel is scrolled up it will go 2. If they
    > do a long scroll it will go 2,3,4,5,6,7,8... Obviously this involved
    > me capturing the event and direction.
    >
    > In IE, we use something like:
    >
    > <input onmousewheel="doInputScroll(event, this);"...
    >
    > .. allows me to capture the event but onmousewheel is only supported
    > by IE. In Firefox I found onscroll as well as some functions on how to
    > capture the direction but event handler can only be applied to certain
    > HTML elements however the only element I had any luck with was <body>.
    > I did consider wrapping my input element in a <div> and applying the
    > event handler to that but it didn't seem to work either for some
    > reason anyway.
    >
    > Does anyone have any ideas how I might get this working? Its not
    > common functionality I know but many of our web users are used to this
    > feature in IE and it would be great to put this over to FF too
    >
    > Cheers
    > Burnsy



    Actually mousewheel not only supported from IE. Chrome and Opera too
    dispatched.
    In FF you have DOMMouseScroll.
    https://developer.mozilla.org/en/Gecko-Specific_DOM_Events#section_8
    abozhilov, Sep 2, 2009
    #2
    1. Advertising

  3. bizt

    abozhilov Guest

    abozhilov, Sep 2, 2009
    #3
  4. bizt

    SAM Guest

    Le 9/2/09 4:35 PM, bizt a écrit :
    > Hi,
    >
    > I have a site that Im working on where we have an input tag which has
    > a numeric value. Say that value is 1, I want to apply an event handler
    > where if the mouse scroll wheel is scrolled up it will go 2. If they
    > do a long scroll it will go 2,3,4,5,6,7,8... Obviously this involved
    > me capturing the event and direction.
    >
    > In IE, we use something like:
    >
    > <input onmousewheel="doInputScroll(event, this);"...
    >
    > .. allows me to capture the event but onmousewheel is only supported
    > by IE. In Firefox I found onscroll as well as some functions on how to


    <http://www.quirksmode.org/dom/events/tests/scroll.html>

    > capture the direction but event handler can only be applied to certain
    > HTML elements however the only element I had any luck with was <body>.
    > I did consider wrapping my input element in a <div> and applying the
    > event handler to that but it didn't seem to work either for some
    > reason anyway.


    seems you need to use :
    - an addEventListener catching the target scrolled
    - and the DOMMouseScroll (insteed of mouseWheeel)
    SAM, Sep 2, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page