example from an xsl stylesheet
<a href="http://mywebsite/servlet?param1={xmldata}">link</a>
The xml data may contain values that may not be transported correctly (e.g., &).
A solution that seems to work is
<a onclick="this.href+=encodeURIComponent('{xmldata}');" href="http://mywebsite/servlet?param1=">link</a>
Note: Javascript has different functions for encoding URLs. Refer this.
Main points to remember about the various functions are
- escape() will not encode: @*/+
- encodeURI() will not encode: !@#$&*()=:/;?+'
- encodeURIComponent() will not encode: !*()'
No comments:
Post a Comment