Re: Calling 2 functions from JavaScript OnMouseOver

Discussion in 'Computer Support' started by VanguardLH, Dec 31, 2010.

  1. VanguardLH

    VanguardLH Guest

    ~~Rob Telp~~ wrote:

    > Is it possible to call 2 functions in the OnMouseOver event itself?
    >
    > Currently I am doing: <a onMouseOver="FUNCTION1()"</a>
    >
    > I would like to call 2 functions if possible: <a onMouseOver="FUNCTION1()
    > FUNCTION2()"</a>
    >
    > If it is possible, what is the syntax and what do I use to separate the 2
    > functions? I have tried a space, comma, semi colon and colon and none
    > appear to work.
    >
    > TIA


    I haven't tested this but I thought the Javascript you specified in the
    string for the event could be like code lines that you write. In other
    words, separate the lines with the semicolon character as you would when
    writing the Javascript alone. Does the following work?

    <a onmouseover="func1();func2()" ...</a>

    If I'm wrong and that doesn't work, why not have a wrapper function that
    calls the other two.

    <a onmouseover="funcmult()"...</a>

    where funcmult calls func1 and func2. Another possibility is where you
    have the onmouseover function for an element defined separately from it,
    as in:

    <a ... id="a1">
    <script type="text/javascript">
    document.getElementById('a1').onmouseover = function(){
    func1();
    func2();
    <any other code>
    }
    </script>

    You define separately the function for the onmouseover event for the
    element that you specify by its id tag. That is, you tag the element
    with an id that can be used later to identify that particular element.
    Then you define its onmouseover property with the [wrapper] function
    that you want to use.

    I'm no Javascript programmer (just have had occasion to get my nose
    pushed into it a few times). A better place to ask would be in a
    Javascript programming group, like:

    comp.lang.javascript
    (or any of the *.javascript newsgroups)
    VanguardLH, Dec 31, 2010
    #1
    1. Advertising

  2. VanguardLH

    MyNews Guest

    Mr. VanguardLH

    I believe wrapper function is the one he looking for!

    "VanguardLH" <> wrote in message
    news:ifk3hg$qsm$...
    > ~~Rob Telp~~ wrote:
    >
    >> Is it possible to call 2 functions in the OnMouseOver event itself?
    >>
    >> Currently I am doing: <a onMouseOver="FUNCTION1()"</a>
    >>
    >> I would like to call 2 functions if possible: <a
    >> onMouseOver="FUNCTION1()
    >> FUNCTION2()"</a>
    >>
    >> If it is possible, what is the syntax and what do I use to separate the 2
    >> functions? I have tried a space, comma, semi colon and colon and none
    >> appear to work.
    >>
    >> TIA

    >
    > I haven't tested this but I thought the Javascript you specified in the
    > string for the event could be like code lines that you write. In other
    > words, separate the lines with the semicolon character as you would when
    > writing the Javascript alone. Does the following work?
    >
    > <a onmouseover="func1();func2()" ...</a>
    >
    > If I'm wrong and that doesn't work, why not have a wrapper function that
    > calls the other two.
    >
    > <a onmouseover="funcmult()"...</a>
    >
    > where funcmult calls func1 and func2. Another possibility is where you
    > have the onmouseover function for an element defined separately from it,
    > as in:
    >
    > <a ... id="a1">
    > <script type="text/javascript">
    > document.getElementById('a1').onmouseover = function(){
    > func1();
    > func2();
    > <any other code>
    > }
    > </script>
    >
    > You define separately the function for the onmouseover event for the
    > element that you specify by its id tag. That is, you tag the element
    > with an id that can be used later to identify that particular element.
    > Then you define its onmouseover property with the [wrapper] function
    > that you want to use.
    >
    > I'm no Javascript programmer (just have had occasion to get my nose
    > pushed into it a few times). A better place to ask would be in a
    > Javascript programming group, like:
    >
    > comp.lang.javascript
    > (or any of the *.javascript newsgroups)


    --
    http://mynews.ath.cx
    MyNews, Dec 31, 2010
    #2
    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.
Similar Threads
  1. Replies:
    1
    Views:
    794
  2. Shane

    To Javascript, or not to Javascript

    Shane, Aug 29, 2005, in forum: NZ Computing
    Replies:
    5
    Views:
    398
    Waylon Kenning
    Aug 30, 2005
  3. MyNews
    Replies:
    0
    Views:
    775
    MyNews
    Dec 31, 2010
  4. richard
    Replies:
    1
    Views:
    806
    MyNews
    Dec 31, 2010
  5. §ñühw¤£f

    Re: Calling 2 functions from JavaScript OnMouseOver

    §ñühw¤£f, Dec 31, 2010, in forum: Computer Support
    Replies:
    5
    Views:
    1,393
    Meat Plow
    Dec 31, 2010
Loading...

Share This Page