473,797 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Single and double quote problems.

Hi all. This isn't quite the same single/double-quote problem we see
posted a multitude of times in this ng. Read on...

I have a js function called ShowActiveLink which accepts a string
containing the full "<a href...>" element. My problem is that some of
the hrefs contain both single and double quotes and I don't have the
ability to escape these characters manually because our content
management system inserts the href when it generates the site.
Therefore I end up with code like this:

<script language="javas cript">
void ShowActiveLink( '<a
href="javascrip t:newWindow('ht tp://www.vre.org/');">VRE Service
Status</a>');
</script>
<a href="javascrip t:newWindow('ht tp://www.vre.org/');">VRE Service
Status</a></li>

....which causes a compiler error.

(Incidentally, the function searches for the current page name inside
the provided href string. If it's found it displays a <li
style="list-style-image: url('images/arrow-right.gif');"> before the
link. Otherwise, it displays an <li> without a bullet.)

Do any of you know a function or something that I can wrap around this
href to escape the string, regardless of how many single or
double-quotes there are, before it is passed to the function?

Thanks,
--Diarmaid.
Jul 23 '05 #1
2 4239
On 10 Nov 2004 06:37:45 -0800, Diarmaid McGleenan
<ca************ @yahoo.com> wrote:
Hi all. This isn't quite the same single/double-quote problem we see
posted a multitude of times in this ng. Read on...
Actually, I think it is, but in any case it is the same question you
posted yesterday. I won't repeat everything I wrote then so if you haven't
done so already, please read my previous post.

[snip]
Do any of you know a function or something that I can wrap around this
href to escape the string, regardless of how many single or
double-quotes there are, before it is passed to the function?


This is a *syntax* error. No amount of function calls can correct that,
only modification of the script itself. You will either have to instruct
your content management system (which I believe you blamed yesterday) to
output \" or \' when writing the string literal, or modify the output
afterwards.

Syntax has to be correct *before* it gets to the client. You can't correct
it afterwards.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2
Thanks for your suggestion Michael, and sorry about the double post
for the same problem. I thought the other message didn't make it to
the ng for whatever reason.

--Diarmaid.
Hi all. This isn't quite the same single/double-quote problem we see
posted a multitude of times in this ng. Read on...


Actually, I think it is, but in any case it is the same question you
posted yesterday. I won't repeat everything I wrote then so if you haven't
done so already, please read my previous post.

[snip]
Do any of you know a function or something that I can wrap around this
href to escape the string, regardless of how many single or
double-quotes there are, before it is passed to the function?


This is a *syntax* error. No amount of function calls can correct that,
only modification of the script itself. You will either have to instruct
your content management system (which I believe you blamed yesterday) to
output \" or \' when writing the string literal, or modify the output
afterwards.

Syntax has to be correct *before* it gets to the client. You can't correct
it afterwards.

Mike

Jul 23 '05 #3

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

Similar topics

12
16422
by: Joshua Beall | last post by:
Hi All, I have heard other people say that PHP can parse double quoted strings (e.g., "Hello, World") faster than it can parse single quoted strings (e.g., 'Hello, World'). This seems backwards to me, since double quote strings have to be checked for any variables that need to be interpreted, whereas single quoted strings do not. So, what is the truth on this matter? And the explanation? Thanks for any information!
2
14482
by: girish | last post by:
In my XML document, some node attributes data contains both single quot and double quote characters, such as <input msg="Hello "World", What's up"/>. The double quotes are in form of escape sequence in the XML document. am not able to locate such elements using an XPath expression. I trie the following: //*
4
10637
by: sankofa | last post by:
hi, i can't seem to be able to escape my single quote properly... is it even possible in javascript? this is a portion of my code.. var DLEWIS="Pastor Lewis"; .... Sermon is a yser-defined class .. var en_20031102=new Sermon("11/02",DLEWIS,"The Lord\'s Supper: The Art Of
5
11459
by: Joel | last post by:
Hi, I incorporated a function in my code that whenever I use a string variable in an sql statement if the string contains a single quote it will encase it in double quotes else single quotes. Queston: How do you handle a string that contains both single & double quotes (i.e. 12'X7") Here's the function:
4
31238
by: Greg | last post by:
I keep getting an error when I have a tick mark in a text value that I am searching for in my XPath Query. Example: <Authors> <Author LastName="O'Donnel"> <Author LastName="Smith"> </Authors>
7
21035
by: gar | last post by:
Hi, I need to replace all the double quotes (") in a textbox with single quotes ('). I used this code text= Replace(text, """", "'" This works fine (for normal double quotes).The problem comes in when you copy a double quote from MS Word and paste it in the text box. What happens is the double quote becomes slanted (“) so my code above can't filter it. I tried to do this text= Replace(text, "““","'")
4
7476
by: Justin Fancy | last post by:
Hi everyone, I need to replace all instances of a double quote(") with two single quotes('') in a text file. I already have some replacements of strings going on, but I tried this one, but the syntax is being read wrong. Here is the code: lineFile1 = sr.ReadLine
116
36004
by: Dilip | last post by:
Recently in our code, I ran into a situation where were stuffing a float inside a double. The precision was extended automatically because of that. To make a long story short, this caused problems elsewhere in another part of the system where that figure was used for some calculation and some eventual truncation led to the system going haywire. So my question is, given this code: int main() { float f = 59.89F;
3
2744
by: Eric Layman | last post by:
Hi, I've saved data into the db by doing a replace() on single quote. Right now on data display on a datagrid, it shows double single quote. How do I make changes during run time of datagrid so that the double single quote will be replaced as single quote? Pls advise.
0
9685
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
9536
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
10245
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
10205
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
9063
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...
1
7559
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5458
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2933
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.