Javascript double quote escape character?

Discussion in 'ASP General' started by Alden Streeter, Nov 24, 2003.

  1. Here is the HTML that is being output by my asp page:

    <a href='Files/category/computers/bigimages/computers-sub-monitors.jpg'
    target='_blank' onMouseOver="window.status='Click for a larger image of
    MONITOR, 19\" CODAR EAGLE.';return true;"
    onMouseOut="window.status='';return true;">
    <img width='98' height='96' border='0'
    src='Files/category/computers/bigimages/computers-sub-monitors.jpg'
    alt='MONITOR, 19" CODAR EAGLE'></a>

    Notice the \" . AFAIK this escape character is what I am supposed to do to
    use a double quote in a string in javascript. But my browser (IE 6.0)
    doesn't like it - it says it is an "unterminated string constant".

    If I change the double quote to a single quote - \' - then the browser works
    as expected: it shows 19' in the status bar. But the monitor I am
    describing is really only 19 inches, not 19 feet, so that's not a real
    option.

    So am I using the escape character wrong, or have I just run into a bug in
    IE6?
     
    Alden Streeter, Nov 24, 2003
    #1
    1. Advertising

  2. "Peter Foti" <> wrote in message
    news:...
    > "Alden Streeter" <> wrote in message
    > news:...
    > > Here is the HTML that is being output by my asp page:
    > >
    > > <a href='Files/category/computers/bigimages/computers-sub-monitors.jpg'
    > > target='_blank' onMouseOver="window.status='Click for a larger image of
    > > MONITOR, 19\" CODAR EAGLE.';return true;"
    > > onMouseOut="window.status='';return true;">
    > > <img width='98' height='96' border='0'
    > > src='Files/category/computers/bigimages/computers-sub-monitors.jpg'
    > > alt='MONITOR, 19" CODAR EAGLE'></a>
    > >
    > > Notice the \" . AFAIK this escape character is what I am supposed to do

    > to
    > > use a double quote in a string in javascript. But my browser (IE 6.0)
    > > doesn't like it - it says it is an "unterminated string constant".
    > >
    > > If I change the double quote to a single quote - \' - then the browser

    > works
    > > as expected: it shows 19' in the status bar. But the monitor I am
    > > describing is really only 19 inches, not 19 feet, so that's not a real
    > > option.
    > >
    > > So am I using the escape character wrong, or have I just run into a bug

    in
    > > IE6?

    >
    > You are using the escape character wrong. This is not a bug. You need to
    > use &quot; instead. As in:
    >
    > ...
    > MONITOR, 19&quot; CODAR EAGLE';return true;"
    >
    > See this portion of the HTML spec for more info on this:
    > http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.2.1
    >
    > Regards,
    > Peter Foti


    Thanks! That works without the hack. I knew it couldn't have been a bug in
    IE ;-)
     
    Alden Streeter, Nov 26, 2003
    #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. Replies:
    3
    Views:
    13,240
  2. Eric Layman
    Replies:
    3
    Views:
    630
    Rad [Visual C# MVP]
    Apr 14, 2007
  3. Sanjeev
    Replies:
    3
    Views:
    1,719
    Andrea Francia
    May 3, 2008
  4. Evan
    Replies:
    3
    Views:
    522
    Marc 'BlackJack' Rintsch
    Nov 4, 2008
  5. Alvaro Perez

    Double quote escape character

    Alvaro Perez, Aug 16, 2007, in forum: Ruby
    Replies:
    11
    Views:
    243
    Phrogz
    Aug 16, 2007
Loading...

Share This Page