473,769 Members | 6,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="wi ndow.status='Cl ick for a larger image of
MONITOR, 19\" CODAR EAGLE.';return true;"
onMouseOut="win dow.status='';r eturn 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 "unterminat ed 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 21412
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="wi ndow.status='Cl ick for a larger image
of MONITOR, 19\" CODAR EAGLE.';return true;"
onMouseOut="win dow.status='';r eturn 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 "unterminat ed 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="wi ndow.status=msg ;return true;"
onMouseOut="win dow.status='';r eturn 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******@NOyah oo.SPAMcom> wrote in message
news:ug******** ******@TK2MSFTN GP09.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="wi ndow.status='Cl ick for a larger image
of MONITOR, 19\" CODAR EAGLE.';return true;"
onMouseOut="win dow.status='';r eturn 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 "unterminat ed 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="wi ndow.status=msg ;return true;"
onMouseOut="win dow.status='';r eturn 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******** ******@TK2MSFTN GP12.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="wi ndow.status='Cl ick for a larger image of
MONITOR, 19\" CODAR EAGLE.';return true;"
onMouseOut="win dow.status='';r eturn 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 "unterminat ed 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****@systoli cnetworks.com> wrote in message
news:vs******** ****@corp.super news.com...
"Alden Streeter" <as************ ****@srca.net> wrote in message
news:es******** ******@TK2MSFTN GP12.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="wi ndow.status='Cl ick for a larger image of
MONITOR, 19\" CODAR EAGLE.';return true;"
onMouseOut="win dow.status='';r eturn 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 "unterminat ed 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
8262
by: sinister | last post by:
The examples in the online manual all seem to use double quotes, e.g. at http://us3.php.net/preg_replace Why? (The behavior is different with single quotes, and presumably simpler to understand.)
7
2628
by: JZ | last post by:
I hope there is someone out there that can suggest a solution to my problem. So here we go: $command="myapp.exe -P d:\mydir\mySubDir"; echo "<td><a href=\"javascript:LaunchApp('$command')\">blah</a></td>"; This works fine. But when 'mySubDir' becomes 'my Sub Dir' myapp requires quotes: myapp.exe -P "d:\mydir\my Sub Dir"
5
2748
by: Gary Mayor | last post by:
Hi, If I have the ' character within the javascript:pick command it doesn't work. Is there some sort of way of escaping these characters like in server side languages. function pick(symbol) { if (window.opener && !window.opener.closed) window.opener.document.create.text1.value = symbol; window.close(); }
6
5133
by: Denis | last post by:
I am trying to launch an .mdb file via javascript. I do not need to do anything but open the application. It is able to open the application but for some reason it opens and then closes. At first I thought it may be a permission problem as far as writing the .ldb file to disk, but I added every single user and gave them write permissions to the folder and there is still no change. Has anyone been able to get this to work? Thanks in...
5
2208
by: Lucian Sandor | last post by:
Hello everyone, While I'm a newbie here, I a not new to google, so please don't send me back, it would be useless. First of all I have to specify I am working on a Blogger.com template, therefore anything I'll write should be stuck on a single file. I thought about creating a funny pop-up. <a href="javascript:myFunction();"... that's because, as you will see, the code for the popup is pretty complex. I've insterted myFunction somewhere...
12
9645
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" & Chr(34) & PopUpWindowTitle & Chr(34) & ", " & Chr(34) & CurrentEventDetails & ")" strTemp += "<BR><A HREF='#' onClick='" & PopupLink & "'>" & EventName & "</A><BR>" The problem I have is that when the string variables or contain a string with an...
10
47534
by: korund | last post by:
We can use special characters ('\n') to add line breaks in text in JavaScript popup Alert boxes. there is also few additional special characters: \' single quote \" double quote \& ampersand \\ backslash \n new line
25
5650
by: Peter Michaux | last post by:
Hi, I'm thinking about code minimization. I can think of a few places where whitespace matters a + ++b a++ + b a - --b a-- -b when a line ends without a semi-colon in which case the new line
7
13047
by: JohnF | last post by:
I have a function textag($expression){...} whose $expression argument is a string that can contain substrings like \alpha with one backslash or like a&b\\c&d with two backslashes. If I write <?php textag('\alpha'); ?with the expression argument in single quotes, then that works fine, and the single backslash isn't interpreted or changed, which is what I want. But if I write <?php textag('a&b\\c&d'); ?>
0
9590
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9424
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10051
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10000
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8879
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3968
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.