By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

Attach Events

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.