473,395 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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(elementObject.onmouseover) { doThis(); } ] but that does not seem
to work. What I am looking for is something like:

<a href="somedoc.htm" onMouseOver="mouseEvent(this);"
onMouseOut="mouseEvent(this);">some link text</a>
<SCRIPT language="javascript"><!--
function mouseEvent(elementObject) {
if(elementObject.onmouseover) { // or whatever syntax to test
doSomething();
} else if(elementObject.onmouseout) { // again, whatever...
doSomethingElse();
}
}
// --></SCRIPT>
Thanks in advance for any help!

Kathy Lynn
Jul 20 '05 #1
3 2414
Hi Kathy (I note that Catherine starts with C),

If I understand you right, you are talking about
<a href="somedoc.htm" onMouseOver="mouseEvent(this,event);"
onMouseOut="mouseEvent(this,event);">some link text</a>

<SCRIPT type="text/javascript"><!--
function mouseEvent(elementObject, evt) {
var e = evt || window.event;
if (e.type == "mouseover") { // double check capitalization
doSomething();
} else if(e.type=="mouseout") { // 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.javascript) 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" <kl*****@hotmail.com> wrote in message news:5f**************************@posting.google.c om...
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(elementObject.onmouseover) { doThis(); } ] but that does not seem
to work. What I am looking for is something like:

<a href="somedoc.htm" onMouseOver="mouseEvent(this);"
onMouseOut="mouseEvent(this);">some link text</a>
<SCRIPT language="javascript"><!--
function mouseEvent(elementObject) {
if(elementObject.onmouseover) { // or whatever syntax to test
doSomething();
} else if(elementObject.onmouseout) { // again, whatever...
doSomethingElse();
}
}
// --></SCRIPT>
Thanks in advance for any help!

Kathy Lynn

Jul 20 '05 #2
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" <ne**@CsabaGabor.com> wrote in message news:<bk********@dispatch.concentric.net>...
Hi Kathy (I note that Catherine starts with C),

If I understand you right, you are talking about
<a href="somedoc.htm" onMouseOver="mouseEvent(this,event);"
onMouseOut="mouseEvent(this,event);">some link text</a>

<SCRIPT type="text/javascript"><!--
function mouseEvent(elementObject, evt) {
var e = evt || window.event;
if (e.type == "mouseover") { // double check capitalization
doSomething();
} else if(e.type=="mouseout") { // 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.javascript) 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" <kl*****@hotmail.com> wrote in message news:5f**************************@posting.google.c om...
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(elementObject.onmouseover) { doThis(); } ] but that does not seem
to work. What I am looking for is something like:

<a href="somedoc.htm" onMouseOver="mouseEvent(this);"
onMouseOut="mouseEvent(this);">some link text</a>
<SCRIPT language="javascript"><!--
function mouseEvent(elementObject) {
if(elementObject.onmouseover) { // or whatever syntax to test
doSomething();
} else if(elementObject.onmouseout) { // again, whatever...

doSomethingElse();
}
}
// --></SCRIPT>
Thanks in advance for any help!

Kathy Lynn

Jul 20 '05 #3
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.onmouseup 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" <kl*****@hotmail.com> wrote in message news:5f**************************@posting.google.c om...
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" <ne**@CsabaGabor.com> wrote in message news:<bk********@dispatch.concentric.net>...
Hi Kathy (I note that Catherine starts with C),

If I understand you right, you are talking about
<a href="somedoc.htm" onMouseOver="mouseEvent(this,event);"
onMouseOut="mouseEvent(this,event);">some link text</a>

<SCRIPT type="text/javascript"><!--
function mouseEvent(elementObject, evt) {
var e = evt || window.event;
if (e.type == "mouseover") { // double check capitalization
doSomething();
} else if(e.type=="mouseout") { // 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.javascript) 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" <kl*****@hotmail.com> wrote in message news:5f**************************@posting.google.c om...
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(elementObject.onmouseover) { doThis(); } ] but that does not seem
to work. What I am looking for is something like:

<a href="somedoc.htm" onMouseOver="mouseEvent(this);"
onMouseOut="mouseEvent(this);">some link text</a>
<SCRIPT language="javascript"><!--
function mouseEvent(elementObject) {
if(elementObject.onmouseover) { // or whatever syntax to test
doSomething();
} else if(elementObject.onmouseout) { // again, whatever...

doSomethingElse();
}
}
// --></SCRIPT>
Thanks in advance for any help!

Kathy Lynn

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would...
3
by: Carl Lindmark | last post by:
*Cross-posting from microsoft.public.dotnet.languages.csharp, since I believe the question is better suited in this XML group* Hello all, I'm having some problems understanding all the ins and...
4
by: MLH | last post by:
It has been mentioned that a ghosted machine or a machine linked by cable modem and USB may result in my reading a MAC address other than one burned onto a NIC in the machine. That being the case,...
3
by: Robert | last post by:
I need some assistance doing some "right way to do it" coding. The following are EventHandlers associated with Delegates in a child form that call a procedure in the MDI form that resets a timer....
1
by: Timo | last post by:
I haven't tried coding eventhandlers in Global.asax yet -- any "gotchas" I should be aware of? Do programming errors there require bouncing IIS? Will handlers in Global.asax be able to access...
3
by: Armin | last post by:
Hello I have a UserControl with a Click Event. Is it possible to find out the List of all Delegates/Eventhandlers using the Event. I read something about a "getinvocationlist" Methode for...
1
by: hzgt9b | last post by:
(FYI, using VB .NET 2003) Can someone help me with this... I'm trying to read in an XML file... it appears to work in that the DataSet ReadXML method dose not fail and then I am able to access the...
1
by: Kasper Birch Olsen | last post by:
Hi NG Im adding a bunch of linkbuttons to a page, in a for loop, but I cant get the eventhandlers to work. A simplyfied version of the code looks like this: for (int i = 0; i<10; i++) {...
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.