Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Unterminated string literal in Javascript
herald10
Hi,
I have this function call in a jsp:
<a
href='javascript:setProp("O'hare");'>O'Hare</a>
When I click on that link nothing happens. And the javascript console in Netscape shows the following error:
unterminated string literal.
I tried escaping using \. But it doesnt work.
Any help is appreciated
Thanks
-H
Find more posts tagged with
Comments
herald10
Never mind. I had to replace the single quote with "
Migrateduser
You could also put multiple escape characters there and it would work just as well.
Dave
Current Environment(s):
(1) TS 6.5 on W2K3
(2) TS 6.1 SP1 on W2K3
By the way, I miss Unix terribly.
herald10
It throws the same error when I try to do that by putting around 2-4 escaping characters.
Thanks
-H
Migrateduser
Sorry, that was hard for me to see, but I copied your text into another editor and I can see it better now (I'm complaining about my sight at the ripe old age of 28!)
If you were to switch around your double and single quotes, that is:
href=
"
javascript:setProp(
'
O
\
'hare
'
);
"
That
should
work. Your syntax should also work, but I don't usually use single quotes as the outer-most delimiter. You might need to escape O'Hare twice, but that's trivial.
Dave
Current Environment(s):
(1) TS 6.5 on W2K3
(2) TS 6.1 SP1 on W2K3
By the way, I miss Unix terribly.
herald10
Thanks for your responses Dave!
We used ' initially, but IE didn't recognize it as the entity for a single quote, but on Firefox it was ok. So we ended up using ' instead. Just now checked your suggestion. It works too.
Thanks
-H