473,396 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Unable to escape characters. What now?

I have a javascript function called ShowActiveLink to which I pass a
full <a href="blah.htm"
onClick="javascript:newWindow('quotedStuff');"> link. (See below.)

---------------
<script language="javascript">void ShowActiveLink('<a
href="javascript:newWindow('http://www.vre.org/');"
target="_blank">VRE Service Status</a>');</script>

<a href="javascript:newWindow('http://www.vre.org/vremap/app?action=ovmap');"
target="_blank">VRE Service Status</a></li>
---------------

My problem is that I have no method of escaping the single quotes in
newWindow('') because the entire <a href> is placed there dynamically
by our content management system when the file is generated.

I've thought of

void ShowActiveLink(escape('<a href="javascript:newWindow('...')'));

but it doesn't work because of the single quotes contained within the
<a href>. I thought of using VBScript, but that doesn't work either
since the double quotes in the link cause the string to close too
early and the compiler blows up.

Keeping in mind that I can't manually escape the href, what can I do
now?
Jul 23 '05 #1
2 1611
"Diarmaid McGleenan" <ca************@yahoo.com> wrote in message
news:94**************************@posting.google.c om...
I have a javascript function called ShowActiveLink to which I pass a
full <a href="blah.htm"
onClick="javascript:newWindow('quotedStuff');"> link. (See below.)

---------------
<script language="javascript">void ShowActiveLink('<a
href="javascript:newWindow('http://www.vre.org/');"
target="_blank">VRE Service Status</a>');</script>

<a href="javascript:newWindow('http://www.vre.org/vremap/app?action=ovmap');" target="_blank">VRE Service Status</a></li>
---------------

My problem is that I have no method of escaping the single quotes in
newWindow('') because the entire <a href> is placed there dynamically
by our content management system when the file is generated.

I've thought of

void ShowActiveLink(escape('<a href="javascript:newWindow('...')'));

but it doesn't work because of the single quotes contained within the
<a href>. I thought of using VBScript, but that doesn't work either
since the double quotes in the link cause the string to close too
early and the compiler blows up.

Keeping in mind that I can't manually escape the href, what can I do
now?


Try using the backquote ( ` ) character instead; I think this works...
Jul 23 '05 #2
On Tue, 09 Nov 2004 18:05:36 GMT, McKirahan <Ne**@McKirahan.com> wrote:
"Diarmaid McGleenan" <ca************@yahoo.com> wrote in message
news:94**************************@posting.google.c om...
[snip]
<script language="javascript">
Not related to a solution, but the language attribute has been deprecated
for over six years. Use the (required) type attribute instead:

<script type="text/javascript">

[snip]
void ShowActiveLink(escape('<a href="javascript:newWindow('...')'));
Three points:

1) What is the purpose of the "void"?
2) See <URL:http://jibbering.com/faq/#FAQ4_24>.
3) The escape function escapes the contents of a string. That string still
has to be valid.

[snip]
Keeping in mind that I can't manually escape the href, what can I do
now?


You have no choice. You *have* to escape the innermost quotes with a
backslash.
Try using the backquote ( ` ) character instead; I think this works...


No, it doesn't.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: BTnews | last post by:
Hi, Can anyone here point me at a definitive guide or tutorial about using escape characters when building SQL queries from user entered data? I'm especially interested in info on this in regard...
7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
18
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1...
4
by: Guadala Harry | last post by:
I need to place the following into a string... How can I properly escape the % " / < and > characters? <table width="100%" border="0" cellspacing="0" cellpadding="4px" class="hfAll"></Table> ...
12
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(" &...
3
by: Guadala Harry | last post by:
I'd like to know the answer to the following question so I can know what to expect with regard to other similar uses of escape characters and strings. While everything works fine - I'd like to know...
15
by: pkaeowic | last post by:
I am having a problem with the "escape" character \e. This code is in my Windows form KeyPress event. The compiler gives me "unrecognized escape sequence" even though this is documented in MSDN....
1
by: sathyp | last post by:
Public Function SetPrinterDefaultsW(ByVal sPrinterName As String, _ ByVal nPaperSize As Long, ByVal nOrientation As Long) As Boolean Dim Prn As Printer Dim hPrinter As Long Dim pd As...
131
by: Lawrence D'Oliveiro | last post by:
The "escape" function in the "cgi" module escapes characters with special meanings in HTML. The ones that need escaping are '<', '&' and '"'. However, cgi.escape only escapes the quote character if...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.