• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

HELP: Tricky display...

Note original post wi. right formating may be found here: http://www.dslreports.com/forum/remark,15879283

Hmmm what work around could you think of where:

by calling a JSP tag:
[code]
<c:out value="${item.title}">[/code]
what becomes:
[code]
The "special" season has arrived.[/code]
As you can see the title has double quotes in them;
However the double quotes are transformed into:
[code]
&#34;[/code]
the " - double quotation mark
but that still makes a JavaScript fail when used like so:
[code]
<a href=# onclick='javascript=alert("<c:out value="${item.title}">");'>onclick avascript alert</a>
as it becomes:
<a href=# onclick='javascript=alert("The &#34;special&#34; season has arrived.");'>onclick avascript alert</a>
what fails
 
Idealy we would have:
<a href=# onclick='javascript=alert("The \"special\" season has arrived.");'>onclick avascript alert</a>
 
but I do not have control over what
<c:out value="${item.title}">
returns (it's just a functionality give to me)[/code]
What do you think would be a good work around to make the tag work inside of a JavaScript...

Any tips, tricks, links, suggestions are much appreciated ;)

<I>Thank you all...</I>
0
InGearX
Asked:
InGearX
1 Solution
 
TimYatesCommented:
http://news.hping.org/comp.lang.javascript.archive/18226.html

Seems to show that you can use a DIV and innerHTML to get these codes converted to their real chars...

I would probably try to avoid using alert() as it never looks nice
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now