1

I am trying to call one javascript function in between my query string in the following manner but its not working......Can anybody point out whether i am doin it correctly or not? My motive is to remove special characters(#,& etc.) from one of the parameters(appName) in my query string............plz help!!

<a target="_self" onmouseout="hideTooltip()" onmouseover="showTooltip(event,'click on the name for additional details');return false" class="tip" href='<%=request.getContextPath()%>/index.jsp?page=myhome&type=details&appName=javascript:escape('<%=adMetricsVO.getApplicationName()%>')&Id=<%=bean.getID()%>'><%= bean.getName()%></a>
1
  • You cannot run JavaScript inside the href attribute -- it's not a JavaScript-aware attribute. Commented Nov 28, 2010 at 19:53

2 Answers 2

2

That's very wrong. (and impossible to do as you're attempting)

You should escape the getApplicationName() on the server.
You need to URL-encode it, then attribute-encode it.

Sign up to request clarification or add additional context in comments.

Comments

1

That's not going to work because the Javascript interpreter won't be involved with the ordinary "click" behavior of the element. In other words, Javascript is never going to see that "href" value.

To make that work, you could either escape the application name on the server, or else put the URL together in a separate piece of Javascript that you wire up to the window "load" event, or something like that.

Alternatively you could have the "click" handled by a Javascript handler that makes the URL and reloads the page.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.