471,319 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Attach Events

Hey,

I know this has probbly been asked 100's of times, but i have yet to
manage to find anyone asking what i am about to ask in this mannor.

Basically here is the code:

strFunction =
ShowImg('GissFactory','auto','auto','100','100','G issFactPic','auto','auto')
if (objArea.addEventListener) {
objArea.addEventListener ("MouseOver",strFunction,false);
else if (objArea.attachEvent) {
objArea.attachEvent ("onMouseOver",strFunction);
} else {
objArea.onMouseOver = strFunction;
}

(Normally this is in a function, and the function would inclued the
strFunction)

but i keep getting a type missmatch, i think it is something to do with
the Variables that are being passed but i am not 100% sure. i ahve
tryed it with no varables being passed and still had the same, so then
i tryed it with the string inplace and it worked, but it is going to be
passing variable events to it so is there anyway taht i can has it so
that i can pass the Variable strFunciton to define the function.

Thank you in advance
Chris

Aug 28 '06 #1
4 1550
De****@gmail.com wrote:

[snip]
strFunction =
ShowImg('GissFactory','auto','auto','100','100','G issFactPic','auto','auto')
Do you realise that you're assigning the return value from /calling/ the
ShowImg function here? If so, what's the value returned?
if (objArea.addEventListener) {
objArea.addEventListener ("MouseOver",strFunction,false);
else if (objArea.attachEvent) {
objArea.attachEvent ("onMouseOver",strFunction);
} else {
objArea.onMouseOver = strFunction;
}
Your use of case here unwise (and wrong, in the latter case): use all
lower case (mouseover/onmouseover) for event names.

[snip]

Mike
Aug 28 '06 #2
Hey mike,

Thank you for your reply.
Ohh sorry that was a mistake, i jsut wrote that code in here as a
example to show you all but left the "" off so what it should read is:

strFunction =
"ShowImg('GissFactory','auto','auto','100','100',' GissFactPic','auto','auto')"

and thankyou i ahve now changed the case to all lower, but is till have
the same problem of type mismatch when i try to add the function.

Regards
Chris

Michael Winter wrote:
De****@gmail.com wrote:

[snip]
strFunction =
ShowImg('GissFactory','auto','auto','100','100','G issFactPic','auto','auto')

Do you realise that you're assigning the return value from /calling/ the
ShowImg function here? If so, what's the value returned?
if (objArea.addEventListener) {
objArea.addEventListener ("MouseOver",strFunction,false);
else if (objArea.attachEvent) {
objArea.attachEvent ("onMouseOver",strFunction);
} else {
objArea.onMouseOver = strFunction;
}

Your use of case here unwise (and wrong, in the latter case): use all
lower case (mouseover/onmouseover) for event names.

[snip]

Mike
Aug 28 '06 #3
De****@gmail.com wrote:

[snip]
Ohh sorry that was a mistake, i jsut wrote that code in here as a
example to show you all but left the "" off so what it should read is:

strFunction =
"ShowImg('GissFactory','auto','auto','100','100',' GissFactPic','auto','auto')"
Then you /are/ repeating past issues.

The listener argument passed to event-related functions, or the value
assigned to event properties, is a function object reference, not a string.

A simple replacement is:

var listener = function() {
ShowImg('GissFactory', 'auto', 'auto', '100', '100',
'GissFactPic', 'auto', 'auto');
};

You'd then replace strFunction with listener in your previously posted code.

There may be alternative approaches which are more suitable, especially
if the above may trigger MSIE's notorious memory leak.

Mike
Please do not top-post to this group. Please read
<http://www.safalra.com/special/googlegroupsreply/before using Google
Groups to reply.
Aug 28 '06 #4
Hey Mike,

Thank you for the reply,
That is a work arround that i could use.
Thank you for your help.
Chris
Michael Winter wrote:
De****@gmail.com wrote:

[snip]
Ohh sorry that was a mistake, i jsut wrote that code in here as a
example to show you all but left the "" off so what it should read is:

strFunction =
"ShowImg('GissFactory','auto','auto','100','100',' GissFactPic','auto','auto')"

Then you /are/ repeating past issues.

The listener argument passed to event-related functions, or the value
assigned to event properties, is a function object reference, not a string.

A simple replacement is:

var listener = function() {
ShowImg('GissFactory', 'auto', 'auto', '100', '100',
'GissFactPic', 'auto', 'auto');
};

You'd then replace strFunction with listener in your previously posted code.

There may be alternative approaches which are more suitable, especially
if the above may trigger MSIE's notorious memory leak.

Mike
Please do not top-post to this group. Please read
<http://www.safalra.com/special/googlegroupsreply/before using Google
Groups to reply.
Aug 28 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Aymer | last post: by
1 post views Thread by Robert Oschler | last post: by
4 posts views Thread by bhatiaajay | last post: by
4 posts views Thread by Julie J. | last post: by
reply views Thread by dermot | last post: by
reply views Thread by rosydwin | last post: by

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.