Since someone recently asked me about this ... I didn't figure out a solution, but I figured out a workaround that was good enough for my purposes.
In the onclick event handler for the link I call "this.childNodes.item(0).nodeValue" which gets the body of the link - that is the text that is displayed to the user. This works for me because the text I want to return is the same as the text I want to display to the user in the link. Note that the javascript must be in an event handler (like onclick) and not in the href. <% session.setAttribute("x","Dan's Test"); %> <% session.setAttribute("y","The \"other\" test"); %> <a href="#" onclick="alert(this.childNodes.item(0).nodeValue)"><bean:write name="x"/></a><BR> <a href="#" onclick="alert(this.childNodes.item(0).nodeValue)"><bean:write name="y"/></a><BR> Works in IE and Firefox/Mozilla (and I assume other browsers too). - Dan > -----Original Message----- > From: Daniel Lipofsky > Sent: Thursday, January 22, 2004 5:22 PM > > No, that doesn't fix it. It needs to be encoded. > It just needs to be encoded as "Dan\'s Test" > or even as "Dan\'s" but not as "Dan's". > The problem is that the brower converts ' > back to a single quote early on in the game, > and then the single quote prematurely ends the string I > am trying to pass to the Javascript method, which > causes a Javascript exception. > Thanks, > Dan > > > -----Original Message----- > > From: Yee, Richard K,,DMDCWEST [mailto:[EMAIL PROTECTED] > > Sent: Thursday, January 22, 2004 4:39 PM > > > > Dan, > > Try using the filter="false" attribute of the bean:write tag. > > That will > > disable the encoding of characters that are sensitive to HTML. > > > > > > -Richard > > > > -----Original Message----- > > From: Daniel Lipofsky [mailto:[EMAIL PROTECTED] > > Sent: Thursday, January 22, 2004 4:18 PM > > To: [EMAIL PROTECTED] > > Subject: bean:write and apostrophes > > > > > > If I use <bean:write ... filter=true> > > to write out the value "Dan's Test" I get "Dan's". > > But this is giving me problems with Javascript. > > > > THIS FAILS: > > <a href="javascript:alert('Dan's Test')">Dan's Test</a> > > > > BUT THIS WORKS: > > <a href="javascript:alert('Dan\'s Test')">Dan's Test</a> > > > > But I don't know how to get the second form. > > I can reverse the single quotes and double quotes > > in javascript - then it works for the test case above > > but fails for strings with double quotes. > > > > Has anyone solved this problem? > > I am using IE 6.0 as my browser as struts 1.1. > > Here is the full test cases: > > > > <% session.setAttribute("x","Dan's Test"); %> > > <% session.setAttribute("y","The \"other\" test"); %> > > <a href="javascript:alert('<bean:write name="x"/>')">x1</a><BR> <a > > href="javascript:alert('<bean:write name="y"/>')">y1</a><BR> <a > > href='javascript:alert("<bean:write name="x"/>")'>x2</a><BR> <a > > href='javascript:alert("<bean:write name="y"/>")'>y2</a><BR> > > > > Thanks, > > Dan --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]