Param undefined for onmouseover function! Help

J

james

OK, I have the following javascript functions:

var TimerID = null;

function onMouseOverHandler(oPopup) {
if (TimerID) {
clearTimeout(TimerID);
}
TimerID = setTimeout(" + oPopup + ", 1500);
}



function onMouseOutHandler() {
if (TimerID) {
clearTimeout(TimerID);
}
// set visibility to hidden
}

I then set the calls up for the function as (server side c# code):

....
{
sPopup = "showtrail('" + sPicPath2 + "','" +
oPic.Title + "','" + oPic.ScreenName + "','" + oPic.TotalComments +
"','" + oPic.Votes + "', '" + oPic.CategoryName + "','1',240,1)";
}
else
{
sPopup = "showtrail('" + sNotFound + "','***
PREVIEW NOT AVAILABLE ***','" + oPic.ScreenName + "','" +
oPic.TotalComments + "','" + oPic.Votes + "', '" + oPic.CategoryName +
"','1',240,1)";
}
string sClose = "hidetrail()";

oImage2.Attributes["onmouseover"] =
"onMouseOverHandler(" + sPopup + ")";
oImage2.Attributes["onmouseout"] =
"onMouseOutHandler(" + sClose + ")";
....

when the onmouseover event fires and calls the onMouseOverHandler, the
oPopup param shows as undefined. What am I missing?

Any help appreciated!

thanks
 
R

Richard Cornford

james said:
OK, I have the following javascript functions:

var TimerID = null;

function onMouseOverHandler(oPopup) {
if (TimerID) {
clearTimeout(TimerID);
}
TimerID = setTimeout(" + oPopup + ", 1500);
}
{
sPopup = "showtrail('" + sNotFound + "','***
PREVIEW NOT AVAILABLE ***','" + oPic.ScreenName + "','" +
oPic.TotalComments + "','" + oPic.Votes + "', '" +
oPic.CategoryName + "','1',240,1)";
}
string sClose = "hidetrail()";

oImage2.Attributes["onmouseover"] =
"onMouseOverHandler(" + sPopup + ")";
oImage2.Attributes["onmouseout"] =
"onMouseOutHandler(" + sClose + ")";
...

when the onmouseover event fires and calls the onMouseOverHandler,
the oPopup param shows as undefined. What am I missing?
<snip>

When you are debugging client-side code it is rarely helpful to be
looking at the server-side code and trying to deduce what it will be
outputting. Instead it is mush more efficient to use the view-source
facility of the browser and look at the code that gets to he browser.
That code is much more likely to expose whatever it is that cases the
problem.

Here the - sPopup - string appears to be the source code for a function
call. That call is then inserted into the argument for the source code
for the - onmouseOverHandler - function call. The result is along the
lines of:-

onmouseover="onMouseOverHandler(
showtrail(' ... ', ' .... ', ' ... ', ' etc. ')
)"

- thus the argument to - onmouseOverHandler - is the return value from
the - showtrail - function, which is presumably the default - undefined -
value.

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top