SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2001
    Location
    UK
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have an inexplicable javascript error on the line:

    setTimeout("mD("+el+");", speed);

    the error is:

    missing ] after element list

    mD([object HTMLDivElement]);

    el is an element that I have retrieved with getElementByID.

    Does anyone else find that these sort of annoying JS errors occur frequently and can cause your work to grind to a halt.



    or am I just stupid?

  2. #2
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have to see more of your code to tell...

    aDog

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wouldn't you need to do an eval() there

    Code:
    setTimeout(eval("mD("+el+")"), speed);

    Just a guess and certianly not tested.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  4. #4
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    An eval(), in this case, shouldn't be needed (this is based from experience and not tested). When you would run the code:

    Code:
    setTimeout(eval("mD("+el+")"), speed);
    The eval() would create:

    md(el)

    where el would be evaluated out to it's value. Then, from there, it would be run in a setTimeout() (which would need the absent quotation marks), so it wouldn't work. However, you could run:

    Code:
    setTimeout('eval("mD("+el+")")', speed);
    Which would work, but so would his original code (atleast it should).

    WIth the original code, it looks like you're passing the layer object, rather than the layerID, but if you were passing the layerID, you would need to surround it with strings, like:

    Code:
    setTimeout("mD('"+el+"')",speed);


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •