#1
  1. Professional Lay-A-Bout
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Location
    Ann Arbor, Michigan
    Posts
    302
    Rep Power
    16

    Paired quotations in an event handlers.


    Sorry, I wasn't sure if this fell in the grounds of javascript or html?

    Code:
    <a href="#" onClick="document.images['closewindow'].src='images/closewindowdown.gif'; closethewindow(); setTimeout('restoreclosekey()',300);return false;"><img src="images/closewindowup.gif"  border="0" width="101" height="101" class="closewindowposition"  name="closewindow"></a>
    In the setTimeout('restoreclosekey()',300); statement I'd like to send a literal value with the function call. Will not using a '"' terminate the onClick event handler?

    Is it permissable to escape the double quotes with a \?
    Thomas

    Dogs and computers both do everything you tell them.
    But computers don't like their tummies rubbed.
  2. #2
  3. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,133
    Rep Power
    4310
    Since, you're using double quotes in the HTML, you should escape single quotes to further nest quote marks..
    Spreading knowledge, one newbie at a time.

    Learn CSS. | PHP includes | HTML Validator | CSS validator

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  4. #3
  5. Professional Lay-A-Bout
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Location
    Ann Arbor, Michigan
    Posts
    302
    Rep Power
    16
    Originally Posted by Kravvitz
    Since, you're using double quotes in the HTML, you should escape single quotes to further nest quote marks..
    Like This?

    Code:
    setTimeout('restoreclosekey(\'literal\')',300);
    Doesn't this violate the paired quotations rule?

    and wouldn't this:

    Code:
    setTimeout('restoreclosekey(\"literal\")',300);
    prematurely close the event call?

    As you can see I didn't quite understand your answer . Could you expand a little bit please?
    Thomas

    Dogs and computers both do everything you tell them.
    But computers don't like their tummies rubbed.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Dec 2003
    Posts
    1,037
    Rep Power
    31
    The first example is right. The last example is wrong because it is HTML causing the problem and \ to escape is a JS thing, so use the top one.

    Comments on this post

    • trumley agrees : Thank You
  8. #5
  9. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,133
    Rep Power
    4310
    Michael is correct.

    Comments on this post

    • trumley agrees : Thank You Too!
    Spreading knowledge, one newbie at a time.

    Learn CSS. | PHP includes | HTML Validator | CSS validator

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).

IMN logo majestic logo threadwatch logo seochat tools logo