double mouseover or function

Discussion in 'Javascript' started by find clausen, Nov 26, 2003.

  1. find clausen

    find clausen Guest

    Why does this not work:

    function flipon(){
    if (!this.filters.flipH) this.style.filter = 'flipH';
    this.filters.flipH.enabled = true;
    }
    function flipoff(){
    this.filters.flipH.enabled = false;
    }

    with this:

    <IMG SRC="../graphics/romoy/bad.jpg" width=350 height=233 alt=""
    border="0" onmouseover="flipon()" onmouseout ="flipoff()">

    This is ok:

    <IMG SRC="../graphics/romoy/bad.jpg" width=350 height=233 alt=""
    border="0" onmouseover="if (!this.filters.flipH) this.style.filter =
    'flipH'; this.filters.flipH.enabled = true;" onmouseout
    ="this.filters.flipH.enabled = false;">

    I would like to put it in a function to use it here too:
    Or how can I put two mouseovers in this:

    <area shape="rect" alt="" coords="45,100,78,123"
    onMouseOver="photo.src='../graphics/romoy/bad.jpg'; return true;">



    --

    find clausen
    www.photopress.dk
     
    find clausen, Nov 26, 2003
    #1
    1. Advertising

  2. find clausen

    Lee Guest

    find clausen said:
    >
    >Why does this not work:
    >
    >function flipon(){
    >if (!this.filters.flipH) this.style.filter = 'flipH';
    >this.filters.flipH.enabled = true;
    >}
    >function flipoff(){
    >this.filters.flipH.enabled = false;
    >}
    >
    >with this:
    >
    ><IMG SRC="../graphics/romoy/bad.jpg" width=350 height=233 alt=""
    >border="0" onmouseover="flipon()" onmouseout ="flipoff()">



    Because "this" doesn't refer to the image except in the
    event handler function. Your event handler needs to pass
    that reference on to the functions that they call:

    function flipon(thisImage){
    if (!thisImage.filters.flipH) thisImage.style.filter = 'flipH';
    thisImage.filters.flipH.enabled = true;
    }
    function flipoff(thisImage){
    thisImage.filters.flipH.enabled = false;
    }

    with this:

    <IMG SRC="../graphics/romoy/bad.jpg" width=350 height=233 alt=""
    border="0" onmouseover="flipon(this)" onmouseout ="flipoff(this)">
     
    Lee, Nov 26, 2003
    #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. Web learner

    from List <double> to double[]

    Web learner, Apr 25, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    485
  2. sb
    Replies:
    4
    Views:
    309
    Alberto Barbati
    Feb 19, 2004
  3. Jacek Dziedzic
    Replies:
    5
    Views:
    385
    Old Wolf
    Apr 8, 2004
  4. Sydex
    Replies:
    12
    Views:
    6,508
    Victor Bazarov
    Feb 17, 2005
  5. Charlie T
    Replies:
    1
    Views:
    98
    Mike Foster
    Sep 8, 2004
Loading...

Share This Page