Param undefined for onmouseover function! Help

Discussion in 'Javascript' started by james, Oct 1, 2006.

  1. james

    james Guest

    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
     
    james, Oct 1, 2006
    #1
    1. Advertising

  2. james wrote:
    > OK, I have the following javascript functions:
    >
    > var TimerID = null;
    >
    > function onMouseOverHandler(oPopup) {
    > if (TimerID) {
    > clearTimeout(TimerID);
    > }
    > TimerID = setTimeout(" + oPopup + ", 1500);
    > }

    <snip>
    > {
    > 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.
     
    Richard Cornford, Oct 1, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Geathaa
    Replies:
    2
    Views:
    703
    Geathaa
    Jul 30, 2003
  2. Mantorok Redgormor
    Replies:
    70
    Views:
    1,776
    Dan Pop
    Feb 17, 2004
  3. ectoplasm
    Replies:
    12
    Views:
    651
    Zorro
    Jul 28, 2005
  4. Replies:
    2
    Views:
    669
    Dave Weaver
    Feb 18, 2009
  5. Dave
    Replies:
    5
    Views:
    686
    John Bokma
    Apr 26, 2011
Loading...

Share This Page