Hi. Question. Say I have <a onclick=' return Outline(this)' onmouseover=' return Outline(this)'>. How could I determine in Outline() that it was launched from a mouseover, as opposed to onclick? 12 1302
Dennis Allen wrote: Hi. Question. Say I have <a onclick=' return Outline(this)' onmouseover=' return Outline(this)'>. How could I determine in Outline() that it was launched from a mouseover, as opposed to onclick?
function Outline(oElement, oEvent) {
var sType = oEvent && oEvent.type || "unknown";
alert(sType);
}
....
<a ...
onclick="return Outline(this, event)"
onmouseover="return Outline(this, event)"
ciao, dhgm
Dietmar Meier wrote on 06 feb 2005 in comp.lang.javascript : <a ... onclick="return Outline(this, event)" onmouseover="return Outline(this, event)"
onclick="return Outline(this, 'onclick')"
onmouseover="return Outline(this, 'onmouseover')"
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Evertjan. wrote: <a ... onclick="return Outline(this, event)" onmouseover="return Outline(this, event)"
onclick="return Outline(this, 'onclick')" onmouseover="return Outline(this, 'onmouseover')"
That's no improvement at all.
ciao, dhgm
Dietmar Meier wrote on 06 feb 2005 in comp.lang.javascript : Evertjan. wrote: <a ... onclick="return Outline(this, event)" onmouseover="return Outline(this, event)"
onclick="return Outline(this, 'onclick')" onmouseover="return Outline(this, 'onmouseover')"
That's no improvement at all.
I think it is. Simplicity usually wins.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
"Evertjan." wrote Dietmar Meier wrote Evertjan. wrote: onclick="return Outline(this, event)" onmouseover="return Outline(this, event)"
onclick="return Outline(this, 'onclick')" onmouseover="return Outline(this, 'onmouseover')"
That's no improvement at all.
I think it is. Simplicity usually wins.
Right, and passing the event with all event handlers is simpler than
hard-coding a different string with every mouseover, click and whathaveyou,
wouldn't you think?
--
Ivo
Ivo wrote on 06 feb 2005 in comp.lang.javascript : "Evertjan." wrote Dietmar Meier wrote > Evertjan. wrote: >>> onclick="return Outline(this, event)" >>> onmouseover="return Outline(this, event)" > >> onclick="return Outline(this, 'onclick')" >> onmouseover="return Outline(this, 'onmouseover')" > > That's no improvement at all.
I think it is. Simplicity usually wins.
Right, and passing the event with all event handlers is simpler than hard-coding a different string with every mouseover, click and whathaveyou, wouldn't you think?
No.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Evertjan. wrote: onclick="return Outline(this, event)" onmouseover="return Outline(this, event)"
onclick="return Outline(this, 'onclick')" onmouseover="return Outline(this, 'onmouseover')"
That's no improvement at all.
I think it is. Simplicity usually wins.
It's not "simple" to write down a string that's already present
as a property of the event object, nor is it "simple" to write
different code for different event handlers where a versatile
variant can be just copied&pasted.
Beyond that you make it harder to maintain: if I have a typo
like "return Outline(this, ebent)", I will most likely get an
error or exeption in this very line, e.g. telling me that there
is no such property. If you have a typo like "return Outline(
this, 'onclock')", you'll most likely get unexpected behaviour
in the function Outline(), thus not in the typo's place.
ciao, dhgm
How about something like:
<script>
function myfun(good,stuff){
if (stuff.type=="click") theevent="click event"
if (stuff.type=="mouseover") theevent="mouse over event"
alert(theevent)
}
</script>
<a id="fred" href="urlhere" onclick="myfun(this,event)"
onmouseover="myfun(this,event)" >Object stuff</a>
further details at: http://www.webreference.com/js/column9/index.html
How about something like:
<script>
function myfun(good,stuff){
if (stuff.type=="click") theevent="click event"
if (stuff.type=="mouseover") theevent="mouse over event"
alert(theevent)
}
</script>
<a id="fred" href="urlhere" onclick="myfun(this,event)"
onmouseover="myfun(this,event)" >Object stuff</a>
Hi,
Howabout something like this:
<script>
function myfun(good,stuff){
if (stuff.type=="click") theevent="click event"
if (stuff.type=="mouseover") theevent="mouse over event"
alert(theevent)
}
</script>
<a id="fred" href="urlhere" onclick="myfun(this,event)"
onmouseover="myfun(this,event)" >Object stuff</a>
For (lots of ) details and browser compatibility check out: http://www.webreference.com/js/column9/index.html
I was hoping for a way that didn't involve passing another parameter, but it'll work...Dennis
"eric" <er********@yahoo.com> wrote in message news:11**********************@l41g2000cwc.googlegr oups.com... Hi, Howabout something like this: <script> function myfun(good,stuff){ if (stuff.type=="click") theevent="click event" if (stuff.type=="mouseover") theevent="mouse over event" alert(theevent) } </script> <a id="fred" href="urlhere" onclick="myfun(this,event)" onmouseover="myfun(this,event)" >Object stuff</a> For (lots of ) details and browser compatibility check out: http://www.webreference.com/js/column9/index.html
Dennis Allen wrote: I was hoping for a way that didn't involve passing another parameter,
but it'll work...Dennis "eric" <er********@yahoo.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com... Hi, Howabout something like this:
<script> function myfun(good,stuff){ if (stuff.type=="click") theevent="click event" if (stuff.type=="mouseover") theevent="mouse over event" alert(theevent) } </script>
<a id="fred" href="urlhere" onclick="myfun(this,event)" onmouseover="myfun(this,event)" >Object stuff</a>
For (lots of ) details and browser compatibility check out: http://www.webreference.com/js/column9/index.html
Just for the sake of argument....
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>untitled</title>
<style type="text/css">
a {
width: 100px;
}
#t {
width: 100%;
height: 560px;
border: none;
font: 11px monospace;
}
</style>
<script type="text/javascript">
function Outline(e)
{
e = e || window.event;
if (e && (txt = document.getElementById('t')))
{
var p, c = [];
for (p in e)
c.push(p + ' ---> ' + e[p]);
txt.value = c.join('\n');
}
}
window.onload = function()
{
document.getElementById('t').value = '';
if (a = document.getElementsByTagName('a').item(0))
{
a.onmouseover = Outline;
a.onmouseout = Outline;
}
}
</script>
</head>
<body>
<a href="#">hoo-hah</a>
<textarea id="t"></textarea>
</body>
</html> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: JKop |
last post by:
Take the following simple function:
unsigned long Plus5Percent(unsigned long input)
{
return ( input + input / 20 );
}
Do yous ever consider the possibly more efficent:
|
by: laredotornado |
last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to
have my Javascript function execute from the BODY's "onload" method,
but if there is already an onload method defined, I would...
|
by: Bern McCarty |
last post by:
I have run an experiment to try to learn some things about floating point
performance in managed C++. I am using Visual Studio
2003. I was hoping to get a feel for whether or not it would make...
|
by: bluejack |
last post by:
Ahoy... before I go off scouring particular platforms for specialized
answers, I thought I would see if there is a portable C answer to this
question:
I want a function pointer that, when...
|
by: dragoncoder |
last post by:
Consider the following code.
#include <stdio.h>
int main()
{
int i =1;
printf("%d ,%d ,%d\n",i,++i,i++);
return 0;
}
|
by: Michael |
last post by:
Hi,
I'm having difficulty finding any previous discussion on this -- I
keep finding people either having problems calling os.exec(lepev), or
with using python's exec statement. Neither of...
|
by: Beta What |
last post by:
Hello,
I have a question about casting a function pointer. Say I want to make
a generic module (say some ADT implementation) that requires a function
pointer from the 'actual/other modules'...
|
by: CryptiqueGuy |
last post by:
Consider the variadic function with the following prototype:
int foo(int num,...);
Here 'num' specifies the number of arguments, and assume that all the
arguments that should be passed to this...
|
by: RandomElle |
last post by:
Hi there
I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with...
|
by: Morten Lemvigh |
last post by:
Is it possible to pass a pointer to a constructor or a class definition
as argument to a function? Maybe in a way similar to passing function
pointers...?
The function should construct a number...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |