469,309 Members | 2,757 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,309 developers. It's quick & easy.

Javascript double quote escape character?

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?
Jul 19 '05 #1
4 21208
Alden Streeter wrote:
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?


I got it working by doing this:

<script type="text/javascript">
<!--
var msg='Click for a larger image of MONITOR, 19" CODAR EAGLE.'
-->
</script>
<a href='Files/category/computers/bigimages/computers-sub-monitors.jpg'
target='_blank'
onMouseOver="window.status=msg;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>

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #2
Thanks! That worked.

I still think it is a bug in IE6 though that the double quote escape
character didn't work, because it does work with the single quote.

"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:ug**************@TK2MSFTNGP09.phx.gbl...
Alden Streeter wrote:
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?


I got it working by doing this:

<script type="text/javascript">
<!--
var msg='Click for a larger image of MONITOR, 19" CODAR EAGLE.'
-->
</script>
<a href='Files/category/computers/bigimages/computers-sub-monitors.jpg'
target='_blank'
onMouseOver="window.status=msg;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>

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Jul 19 '05 #3
"Alden Streeter" <as****************@srca.net> wrote in message
news:es**************@TK2MSFTNGP12.phx.gbl...
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/...html#h-B.3.2.1

Regards,
Peter Foti
Jul 19 '05 #4
"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vs************@corp.supernews.com...
"Alden Streeter" <as****************@srca.net> wrote in message
news:es**************@TK2MSFTNGP12.phx.gbl...
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/...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 ;-)
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by sinister | last post: by
7 posts views Thread by JZ | last post: by
5 posts views Thread by Lucian Sandor | last post: by
10 posts views Thread by korund | last post: by
25 posts views Thread by Peter Michaux | last post: by
7 posts views Thread by JohnF | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.