reading 'type' from eventhandlers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Catherine Lynn Smith

    reading 'type' from eventhandlers

    I'm looking through the client side javascript reference and there's
    some mighty useful information in here, but it is not very specific on
    'reading' information from event handlers.

    In the interest of streamlining my scripting, I was thinking I could
    write multi-purpose functions to handle mouseOver and mouseOut events.
    Thus far, I am manually passing if it is an Over or Out event, but it
    occurs to me that there might be a way to read status of an event
    somewhere. Alas, the web is so full of 'simple' mouseOver and
    mouseOut handling, I have not as of yet refined a search enough to get
    to the information I need.

    I tried just doing a test against the element event [
    if(elementObjec t.onmouseover) { doThis(); } ] but that does not seem
    to work. What I am looking for is something like:

    <a href="somedoc.h tm" onMouseOver="mo useEvent(this); "
    onMouseOut="mou seEvent(this);" >some link text</a>


    <SCRIPT language="javas cript"><!--
    function mouseEvent(elem entObject) {
    if(elementObjec t.onmouseover) { // or whatever syntax to test
    doSomething();
    } else if(elementObjec t.onmouseout) { // again, whatever...
    doSomethingElse ();
    }
    }
    // --></SCRIPT>


    Thanks in advance for any help!

    Kathy Lynn
  • Csaba2000

    #2
    Re: reading 'type' from eventhandlers

    Hi Kathy (I note that Catherine starts with C),

    If I understand you right, you are talking about
    <a href="somedoc.h tm" onMouseOver="mo useEvent(this,e vent);"
    onMouseOut="mou seEvent(this,ev ent);">some link text</a>

    <SCRIPT type="text/javascript"><!--
    function mouseEvent(elem entObject, evt) {
    var e = evt || window.event;
    if (e.type == "mouseover" ) { // double check capitalization
    doSomething();
    } else if(e.type=="mou seout") { // again, whatever...
    doSomethingElse ();
    }
    }
    // --></SCRIPT>

    There have been several detailed discussions about these
    types of events in the last few weeks. Perhaps do a google
    search (in the groups tab) on
    "Csaba Gabor" onmouseover
    In particular, I recommend the two responses by
    Lasse Reichstein Nielsen in the
    ..onmouseover=. .. syntax question re NN events
    thread in this (comp.lang.java script) newsgroup as being
    an excellent, detailed coverage.

    Csaba Gabor from New York

    PS. The this / elementObject are not required in the code above.
    I left them in to show the structure. Another way (shown in the
    google examples) is with e.target || e.srcElement (but this is not
    necessarily the same as what you get with this. For example,
    if you mouse over #text in a TD with the TD's onmouseover
    set, the tartget will be the #text but the elementObject (this)
    will give you the TD).


    "Catherine Lynn Smith" <klynntg@hotmai l.com> wrote in message news:5fb632c2.0 309171210.7402f cca@posting.goo gle.com...[color=blue]
    > I'm looking through the client side javascript reference and there's
    > some mighty useful information in here, but it is not very specific on
    > 'reading' information from event handlers.
    >
    > In the interest of streamlining my scripting, I was thinking I could
    > write multi-purpose functions to handle mouseOver and mouseOut events.
    > Thus far, I am manually passing if it is an Over or Out event, but it
    > occurs to me that there might be a way to read status of an event
    > somewhere. Alas, the web is so full of 'simple' mouseOver and
    > mouseOut handling, I have not as of yet refined a search enough to get
    > to the information I need.
    >
    > I tried just doing a test against the element event [
    > if(elementObjec t.onmouseover) { doThis(); } ] but that does not seem
    > to work. What I am looking for is something like:
    >
    > <a href="somedoc.h tm" onMouseOver="mo useEvent(this); "
    > onMouseOut="mou seEvent(this);" >some link text</a>
    >
    >
    > <SCRIPT language="javas cript"><!--
    > function mouseEvent(elem entObject) {
    > if(elementObjec t.onmouseover) { // or whatever syntax to test
    > doSomething();
    > } else if(elementObjec t.onmouseout) { // again, whatever...
    > doSomethingElse ();
    > }
    > }
    > // --></SCRIPT>
    >
    >
    > Thanks in advance for any help!
    >
    > Kathy Lynn[/color]


    Comment

    • Catherine Lynn Smith

      #3
      Re: reading 'type' from eventhandlers

      OK, now I am running into a different situation that is sort of in the
      same arena. I am going to trigger a setTimeout event from a onClick -
      when it times out, I want to see if the person is still holding the
      mouse down on that element. I assume the best way to do this would be
      checking to see if a mouseDown event still exists in conjunction with
      a mouseOver on the same object.

      But I am still at a loss on the exact way to check if such events are
      currently occuring nor how to check the mouseOver specific to that
      element when the code that will be executed is spawned from the
      timeout rather than an actual mouseOver.

      Any help is appreciated. (even a RTFM that points me to a good source
      for info)

      KL

      "Csaba2000" <news@CsabaGabo r.com> wrote in message news:<bkakau$fb q@dispatch.conc entric.net>...[color=blue]
      > Hi Kathy (I note that Catherine starts with C),
      >
      > If I understand you right, you are talking about
      > <a href="somedoc.h tm" onMouseOver="mo useEvent(this,e vent);"
      > onMouseOut="mou seEvent(this,ev ent);">some link text</a>
      >
      > <SCRIPT type="text/javascript"><!--
      > function mouseEvent(elem entObject, evt) {
      > var e = evt || window.event;
      > if (e.type == "mouseover" ) { // double check capitalization
      > doSomething();
      > } else if(e.type=="mou seout") { // again, whatever...
      > doSomethingElse ();
      > }
      > }
      > // --></SCRIPT>
      >
      > There have been several detailed discussions about these
      > types of events in the last few weeks. Perhaps do a google
      > search (in the groups tab) on
      > "Csaba Gabor" onmouseover
      > In particular, I recommend the two responses by
      > Lasse Reichstein Nielsen in the
      > .onmouseover=.. . syntax question re NN events
      > thread in this (comp.lang.java script) newsgroup as being
      > an excellent, detailed coverage.
      >
      > Csaba Gabor from New York
      >
      > PS. The this / elementObject are not required in the code above.
      > I left them in to show the structure. Another way (shown in the
      > google examples) is with e.target || e.srcElement (but this is not
      > necessarily the same as what you get with this. For example,
      > if you mouse over #text in a TD with the TD's onmouseover
      > set, the tartget will be the #text but the elementObject (this)
      > will give you the TD).
      >
      >
      > "Catherine Lynn Smith" <klynntg@hotmai l.com> wrote in message news:5fb632c2.0 309171210.7402f cca@posting.goo gle.com...[color=green]
      > > I'm looking through the client side javascript reference and there's
      > > some mighty useful information in here, but it is not very specific on
      > > 'reading' information from event handlers.
      > >
      > > In the interest of streamlining my scripting, I was thinking I could
      > > write multi-purpose functions to handle mouseOver and mouseOut events.
      > > Thus far, I am manually passing if it is an Over or Out event, but it
      > > occurs to me that there might be a way to read status of an event
      > > somewhere. Alas, the web is so full of 'simple' mouseOver and
      > > mouseOut handling, I have not as of yet refined a search enough to get
      > > to the information I need.
      > >
      > > I tried just doing a test against the element event [
      > > if(elementObjec t.onmouseover) { doThis(); } ] but that does not seem
      > > to work. What I am looking for is something like:
      > >
      > > <a href="somedoc.h tm" onMouseOver="mo useEvent(this); "
      > > onMouseOut="mou seEvent(this);" >some link text</a>
      > >
      > >
      > > <SCRIPT language="javas cript"><!--
      > > function mouseEvent(elem entObject) {
      > > if(elementObjec t.onmouseover) { // or whatever syntax to test
      > > doSomething();
      > > } else if(elementObjec t.onmouseout) { // again, whatever...[/color]
      > doSomethingElse ();[color=green]
      > > }
      > > }
      > > // --></SCRIPT>
      > >
      > >
      > > Thanks in advance for any help!
      > >
      > > Kathy Lynn[/color][/color]

      Comment

      • Csaba2000

        #4
        Re: reading 'type' from eventhandlers

        Hi Kathy,

        I responding from memory here, so everything I write is more
        suspect than usual. However, from my recollection, this is a
        tough problem (read: I didn't solve it). In particular (and someone
        please correct me where I'm wrong), you can't check mouse status
        like you could check for the control, shift, or alt key status.

        Now, you could keep track of the mouse being released by
        document.onmous eup and checking the target event appropriately.
        Unfortunately, this method can be faked out. If I remember right, in
        IE if you drag off the screen and return, mouse status is lost in some
        circumtstances (though I just checked with a google button and the
        button remembered on IE 5.5/Win 2K) - to compensate you can
        include a check for the mouse leaving the document. I think Netscape
        is nicer about this, and Opera is really whacky. (The following search
        on google Groups gives discusses some aspects of this:
        "csaba gabor" opera onmouseout).

        Please do post back if you get somewhere on this. I'll be most
        interested to learn more on this topic.

        Regards,
        Csaba Gabor from New York


        "Catherine Lynn Smith" <klynntg@hotmai l.com> wrote in message news:5fb632c2.0 310060509.71271 b69@posting.goo gle.com...[color=blue]
        > OK, now I am running into a different situation that is sort of in the
        > same arena. I am going to trigger a setTimeout event from a onClick -
        > when it times out, I want to see if the person is still holding the
        > mouse down on that element. I assume the best way to do this would be
        > checking to see if a mouseDown event still exists in conjunction with
        > a mouseOver on the same object.
        >
        > But I am still at a loss on the exact way to check if such events are
        > currently occuring nor how to check the mouseOver specific to that
        > element when the code that will be executed is spawned from the
        > timeout rather than an actual mouseOver.
        >
        > Any help is appreciated. (even a RTFM that points me to a good source
        > for info)
        >
        > KL
        >
        > "Csaba2000" <news@CsabaGabo r.com> wrote in message news:<bkakau$fb q@dispatch.conc entric.net>...[color=green]
        > > Hi Kathy (I note that Catherine starts with C),
        > >
        > > If I understand you right, you are talking about
        > > <a href="somedoc.h tm" onMouseOver="mo useEvent(this,e vent);"
        > > onMouseOut="mou seEvent(this,ev ent);">some link text</a>
        > >
        > > <SCRIPT type="text/javascript"><!--
        > > function mouseEvent(elem entObject, evt) {
        > > var e = evt || window.event;
        > > if (e.type == "mouseover" ) { // double check capitalization
        > > doSomething();
        > > } else if(e.type=="mou seout") { // again, whatever...
        > > doSomethingElse ();
        > > }
        > > }
        > > // --></SCRIPT>
        > >
        > > There have been several detailed discussions about these
        > > types of events in the last few weeks. Perhaps do a google
        > > search (in the groups tab) on
        > > "Csaba Gabor" onmouseover
        > > In particular, I recommend the two responses by
        > > Lasse Reichstein Nielsen in the
        > > .onmouseover=.. . syntax question re NN events
        > > thread in this (comp.lang.java script) newsgroup as being
        > > an excellent, detailed coverage.
        > >
        > > Csaba Gabor from New York
        > >
        > > PS. The this / elementObject are not required in the code above.
        > > I left them in to show the structure. Another way (shown in the
        > > google examples) is with e.target || e.srcElement (but this is not
        > > necessarily the same as what you get with this. For example,
        > > if you mouse over #text in a TD with the TD's onmouseover
        > > set, the tartget will be the #text but the elementObject (this)
        > > will give you the TD).
        > >
        > >
        > > "Catherine Lynn Smith" <klynntg@hotmai l.com> wrote in message[/color][/color]
        news:5fb632c2.0 309171210.7402f cca@posting.goo gle.com...[color=blue][color=green][color=darkred]
        > > > I'm looking through the client side javascript reference and there's
        > > > some mighty useful information in here, but it is not very specific on
        > > > 'reading' information from event handlers.
        > > >
        > > > In the interest of streamlining my scripting, I was thinking I could
        > > > write multi-purpose functions to handle mouseOver and mouseOut events.
        > > > Thus far, I am manually passing if it is an Over or Out event, but it
        > > > occurs to me that there might be a way to read status of an event
        > > > somewhere. Alas, the web is so full of 'simple' mouseOver and
        > > > mouseOut handling, I have not as of yet refined a search enough to get
        > > > to the information I need.
        > > >
        > > > I tried just doing a test against the element event [
        > > > if(elementObjec t.onmouseover) { doThis(); } ] but that does not seem
        > > > to work. What I am looking for is something like:
        > > >
        > > > <a href="somedoc.h tm" onMouseOver="mo useEvent(this); "
        > > > onMouseOut="mou seEvent(this);" >some link text</a>
        > > >
        > > >
        > > > <SCRIPT language="javas cript"><!--
        > > > function mouseEvent(elem entObject) {
        > > > if(elementObjec t.onmouseover) { // or whatever syntax to test
        > > > doSomething();
        > > > } else if(elementObjec t.onmouseout) { // again, whatever...[/color]
        > > doSomethingElse ();[color=darkred]
        > > > }
        > > > }
        > > > // --></SCRIPT>
        > > >
        > > >
        > > > Thanks in advance for any help!
        > > >
        > > > Kathy Lynn[/color][/color][/color]


        Comment

        Working...