I am trying to have a JavaScript function called when I click a link. This JavaScript function is definied in an attribute of a JSP tag and I am trying to pass a scriptlet variable to the function. However, it doesn't get evaluated. The relevant part of the code is:
<span>
<mysecurity:secure_link id='<%="editButton_"+commentUUID%>' entitlement=""
actionOnClick="editComment('<%= commentUUID %>');return false;"
isSurroundedByBrackets="true" enableTitle="" disableLink="<%=disableLink%>">
<span style="color:#0033BB; font:8pt arial;">
<bean:message key="button.edit" />
</span>
</mysecurity:secure_link>
</span>
IE8 mentions a JavaScript error in the bottom left corner. When I right click and view source, the generated HTML is:
onclick="editComment('<%= commentUUID %>');return false;"
So, the <%=commentUUID%> is not been evaluated in the actionOnClick attribute, but it's successfully been evaluated in id attribute.
How is this caused and how can I fix it?
javascript:does not belong into anonclickattribute. - ThiefMasterjavascript:insideonclick="..."is always unnecessary. - ThiefMasteronclick="editComment(...)". The only time you'd use a javascript: pseudourl is in<a href="javascript:...">...</a>. - Marc B