473,385 Members | 1,655 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,385 software developers and data experts.

function call?

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?
Jul 23 '05 #1
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
Jul 23 '05 #2
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)

Jul 23 '05 #3
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
Jul 23 '05 #4
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)

Jul 23 '05 #5
Ivo
"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
Jul 23 '05 #6
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)

Jul 23 '05 #7
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
Jul 23 '05 #8
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

Jul 23 '05 #9
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>

Jul 23 '05 #10
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

Jul 23 '05 #11
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

Jul 23 '05 #12
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>

Jul 23 '05 #13

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

Similar topics

11
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:
2
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...
13
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...
23
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...
21
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; }
4
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...
3
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'...
9
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...
6
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...
9
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
BarryA
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...
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:
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
Oralloy
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,...
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...

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.