Connecting Tech Pros Worldwide Help | Site Map

function call?

  #1  
Old July 23rd, 2005, 06:36 PM
Dennis Allen
Guest
 
Posts: n/a
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?
  #2  
Old July 23rd, 2005, 06:36 PM
Dietmar Meier
Guest
 
Posts: n/a

re: function call?


Dennis Allen wrote:
[color=blue]
> 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?[/color]

function Outline(oElement, oEvent) {
var sType = oEvent && oEvent.type || "unknown";
alert(sType);
}
....
<a ...
onclick="return Outline(this, event)"
onmouseover="return Outline(this, event)"[color=blue]
>[/color]

ciao, dhgm
  #3  
Old July 23rd, 2005, 06:36 PM
Evertjan.
Guest
 
Posts: n/a

re: function call?


Dietmar Meier wrote on 06 feb 2005 in comp.lang.javascript:[color=blue]
> <a ...
> onclick="return Outline(this, event)"
> onmouseover="return Outline(this, event)"[/color]

onclick="return Outline(this, 'onclick')"
onmouseover="return Outline(this, 'onmouseover')"


--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

  #4  
Old July 23rd, 2005, 06:36 PM
Dietmar Meier
Guest
 
Posts: n/a

re: function call?


Evertjan. wrote:
[color=blue][color=green]
>> <a ...
>> onclick="return Outline(this, event)"
>> onmouseover="return Outline(this, event)"[/color][/color]
[color=blue]
> onclick="return Outline(this, 'onclick')"
> onmouseover="return Outline(this, 'onmouseover')"[/color]

That's no improvement at all.

ciao, dhgm
  #5  
Old July 23rd, 2005, 06:36 PM
Evertjan.
Guest
 
Posts: n/a

re: function call?


Dietmar Meier wrote on 06 feb 2005 in comp.lang.javascript:
[color=blue]
> Evertjan. wrote:[color=green][color=darkred]
>>> <a ...
>>> onclick="return Outline(this, event)"
>>> onmouseover="return Outline(this, event)"[/color][/color]
>[color=green]
>> onclick="return Outline(this, 'onclick')"
>> onmouseover="return Outline(this, 'onmouseover')"[/color]
>
> That's no improvement at all.[/color]

I think it is. Simplicity usually wins.


--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

  #6  
Old July 23rd, 2005, 06:36 PM
Ivo
Guest
 
Posts: n/a

re: function call?


"Evertjan." wrote[color=blue]
> Dietmar Meier wrote[color=green]
> > Evertjan. wrote:[color=darkred]
> >>> onclick="return Outline(this, event)"
> >>> onmouseover="return Outline(this, event)"[/color]
> >[color=darkred]
> >> onclick="return Outline(this, 'onclick')"
> >> onmouseover="return Outline(this, 'onmouseover')"[/color]
> >
> > That's no improvement at all.[/color]
>
> I think it is. Simplicity usually wins.[/color]

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


  #7  
Old July 23rd, 2005, 06:36 PM
Evertjan.
Guest
 
Posts: n/a

re: function call?


Ivo wrote on 06 feb 2005 in comp.lang.javascript:[color=blue]
> "Evertjan." wrote[color=green]
>> Dietmar Meier wrote[color=darkred]
>> > 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.[/color]
>>
>> I think it is. Simplicity usually wins.[/color]
>
> 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?[/color]

No.


--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

  #8  
Old July 23rd, 2005, 06:36 PM
Dietmar Meier
Guest
 
Posts: n/a

re: function call?


Evertjan. wrote:
[color=blue][color=green][color=darkred]
>>>> onclick="return Outline(this, event)"
>>>> onmouseover="return Outline(this, event)"[/color][/color][/color]
[color=blue][color=green][color=darkred]
>>> onclick="return Outline(this, 'onclick')"
>>> onmouseover="return Outline(this, 'onmouseover')"[/color][/color][/color]
[color=blue][color=green]
>> That's no improvement at all.[/color][/color]
[color=blue]
> I think it is. Simplicity usually wins.[/color]

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
  #9  
Old July 23rd, 2005, 06:38 PM
eric
Guest
 
Posts: n/a

re: function call?


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

  #10  
Old July 23rd, 2005, 06:38 PM
eric
Guest
 
Posts: n/a

re: function call?


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>

  #11  
Old July 23rd, 2005, 06:38 PM
eric
Guest
 
Posts: n/a

re: function call?


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

  #12  
Old July 23rd, 2005, 06:38 PM
Dennis Allen
Guest
 
Posts: n/a

re: function call?


I was hoping for a way that didn't involve passing another parameter, but it'll work...Dennis

"eric" <ericcremer@yahoo.com> wrote in message news:1107817797.548584.201450@l41g2000cwc.googlegr oups.com...[color=blue]
> 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
>[/color]
  #13  
Old July 23rd, 2005, 06:39 PM
RobB
Guest
 
Posts: n/a

re: function call?


Dennis Allen wrote:[color=blue]
> I was hoping for a way that didn't involve passing another parameter,[/color]
but it'll work...Dennis[color=blue]
>
> "eric" <ericcremer@yahoo.com> wrote in message[/color]
news:1107817797.548584.201450@l41g2000cwc.googlegr oups.com...[color=blue][color=green]
> > 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
> >[/color][/color]

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>

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
exception handling, function call and memory George2 answers 1 January 31st, 2008 07:45 PM
Why does a VBA function call from a sub-query cause an infinite loop? marcsirois answers 5 December 4th, 2006 08:15 PM
/CLR floating point performance, inter-assembly function call performance Bern McCarty answers 13 November 17th, 2005 02:27 PM
g++ errors out Pass by Reference function call in C++ --- Please HELP mangi03@ca.com answers 4 July 22nd, 2005 11:48 AM
Function call not working, please help! Chris Michael answers 2 July 21st, 2005 08:47 AM